How many solutions does the equation $\sin \left( \frac{\pi}{2} \cos x\right)=\cos \left( \frac{\pi}{2} \sin x\right)$ have in the closed interval $[0,\pi]$? Provide your answer as an integer.

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