n = p^{2}q, where p and q are prime.
So, number of multiple of p in n = pq
Number of multiples of q in n = p^{2}
Number of multiples of pq in n = p
Since prime factorisation of n consists of only p and q, gcd(m, n) will be a multiple of these or 1. So, number of possible m such that gcd(m, n) is 1 will be n - number of multiples of either p or q.
= n - p^{2}-pq+p
= p^{2}q-p^{2}-pq+p
= p(pq-p-q+1)
=p(p-1)(q-1)