Modular simple equation

Let's say I have three known numbers : $a$, $b$ and $m$.

I want to find the smallest $x$ so that $a.x \equiv b\ (mod\ m)$ (the product of $a$ and $b$ is congruent to $b$ modulo $m$).

In the cases where such an $x$ exists, is there a simple equation that allows me to get the value for $x$ ?

Note: the numbers $a$, $b$ and $m$ can be very large numbers. I am looking for a direct resolution of the equation, not a solution involving iterating through all possible values of $x$ or modular-rewriting of $a$ and $b$.

-
There is no simple equation, but there is a simple and efficient algorithm, Euclid's. You'll probably find it explained in several earlier questions on this site. –  Gerry Myerson Aug 24 '12 at 12:45
Thanks for that, Gerry ! –  subtenante Aug 25 '12 at 10:43