A nut has the shape of a regular hexagonal prism. Each side face of the nut is painted in one of three colors: white, red, or blue, and adjacent faces are painted in different colors. How many differently colored nuts exist? (Not all three colors need to be used for the coloring of the nut.)

#
Faces of the same color cannot be adjacent, so there are no more than three of them. Let's consider three cases.

1) Only two colors are used - each three times. Then the colors must alternate, and the only coloring scheme is 121212. By substituting any pair of colors for 1 and 2, we get 3 types of nuts. Swapping the colors in the pair does not change anything.
2) One color is used three times, the second twice, and the third once. Obviously, the coloring scheme (up to rotation) is also unique - 121213. Any of the three given colors can be chosen as color 1, and any of the two remaining as color 2. In total, this gives 6 types of nuts.
3) Each color is used twice. Here, there are two sub-cases.

a) Each face is painted the same as the opposite one: the coloring scheme is 123123. There is only one type of nut of this kind (recall that the nut can be flipped).

b) Some opposite faces are painted in different colors (1 and 2). Then the second face of color 1 is next to the first face of color 2, and vice versa, while the faces of color 3 are opposite each other (scheme 123213). It is important which color we choose as color 3, so this results in 3 types of nuts.

In total, $3+6+1+3=13$ types.