  It is known that the number of homomorphisms from a group $F$ to a group $G$
is divisible by the greatest common divisor of the order of $G$ and the
exponent of $F/[F,F]$. We investigate the number of homomorphisms satisfying
some natural conditions such as injectivity or surjectivity. The simplest
nontrivial corollary of our results is the following fact: {\it in any finite
group, the number of generating pairs $(x,y)$ such that $x^3=1=y^5$, is a
multiple of the greatest common divisor of 15 and the order of the group
$[G,G]\cdot\{g^{15}\;|\;g\in G\}$.
