12. Each vertex of the convex pentagon $A B C D E$ is colored with one of five colors, such that the two endpoints of each diagonal have different colors. The number of such coloring methods is $\qquad$ (answer with a number),
12. 1020 .

The number of coloring ways where all vertices have different colors is $A_{5}^{5}=$ 120. The number of coloring ways where two adjacent vertices have the same color and the rest of the vertices have different colors is
$$
A_{5}^{1} A_{5}^{4}=5(5 \times 4 \times 3 \times 2)=600 \text { ways. }
$$

The number of coloring ways where two pairs of adjacent vertices have the same color and the remaining vertex has a different color is
$$
A_{5}^{1} A_{5}^{3}=5(5 \times 4 \times 3)=300 \text { ways. }
$$

Therefore, there are a total of 1020 coloring ways.