The formula is given in [this question][1], while the answers thereto discuss the accuracy of the obvious approximation (that this is like $a \phi(n)/n.$) [1]: https://mathoverflow.net/questions/88777/bound-the-error-in-estimating-a-relative-totient-function