How to calculate a number of $x$ values such that $f(x)$ is a quadratic residue modulo $m$? Let $a, b$ be any fixed positive integers, $f(x) = (3x + 3a)^2 - b$
How to calculate a number of $x$ values such that $f(x)$ is a quadratic residue modulo $m$ without actually finding them?
Edit: I updated the question to make it more clear.
 A: Step 1: You can ignore the $-b$ since for each residue of $(3x+3a)^2-b$ there is a corresponding residue of $(3x+3a)^2$ whichi s just $b$ more than the former.
Step 2: Similarly you can ignore the $a$ since for each value of $(3x+3a)$ there is a value $(3y)$ with $y=x+a \pmod m$.
So we want to find the number of quadratic residues of the form $(3x)^2 \pmod m$.
If $m$ is a prime greater than $3$, then there are $\frac{m+1}{2}$ quadratic residues $r$ mod $m$, and for each one of those $q$, since $3$ has an inverse mod $m$, 
$x=3^{-1}q\pmod m$ is a number such that $(3x)^2 = r.$  So if $m$ is an odd prime greater than $3$, then the answer is $\frac{m+2}{2}$.
If $m$ is the product of distinct primes all greater than $3$ then again we can find $x=3^{-1}\pmod m$ and the number of quadratic residues matches the number of possble values of $(3x)^2$; and that is the product of the number of quadratic residues for each factor.  So for example, when $m = 5\cdot 11 \cdot 19$ there are 
$3\cdot 6 \cdot 10$ possible values of $3x)^2\pmod m$.
If $m=3$ or $m=9$, then there of course is only one residue, namely $(3x)^2=0$.
Other cases can be solved as well, but counting the residues for an arbitrary prime power is a bit trickier.
