The number of equivalence classes of nondegenerate bilinear and sesquilinear forms over a finite field