For how many positive integers p does there exist a traingle with sides of length 3p-1, 3p, and p^2+1?