The 9 squares of a $3 \times 3$ board, as shown in the figure below, must be painted in such a way that in each row, each column, and each of its two diagonals, there are no squares of the same color. What is the minimum number of colors needed for this painting?

![](https://cdn.mathpix.com/cropped/2024_05_01_ffb48c2069f209c1311cg-10.jpg?height=343&width=347&top_left_y=611&top_left_x=736)

#