I found this question in an old Olympiad from my country, but the solution I found only provides a brute force approach.
The solution said $0$ and $4$, and when it reaches the point it tests $8$, the solution stops there.
I wonder if there is another way to solve it?