Many problems require printing the probability of something. Moreover, it is common that if the answer is $\frac{a}{b}$, you should output $a \times b^{-1} \pmod{p}$ ($p$ is a prime number). In these problems, you cannot know the exact value of the probability. It's so confusing!!! Now, we want to reverse engineer the exact probability from such calculated output value $x$. We do so by guessing the probability is the one with the minimum $b$ such that $a \times b^{-1} = x \pmod{p}$. Now we invite you to solve this problem with us!
You are given two positive integers $p$ and $x$, where $p$ is a prime number.
Please find the smallest positive integer $b$ such that there exist some positive integer $a$ satisfying $a < b$ and $a \equiv bx \pmod{p}$.