For how many primes $p$, does there exist an integer $m$ such that $m^3+3m-2 \equiv 0 \pmod{p}$ and $m^2+4m+5 \equiv 0 \pmod{p}$? Write your answer as an integer.

Let's think step by step and output the final answer within \boxed{}.
user