It's helpful to remark that each vertex of $a,b,c$ is connected to each vertex of $d,e,f$.
This graph is called $K_{3,3}$, the complete bipartite graph of size $(3,3)$ and many things are known about it, but there's also the direct approach:
If $a,b,c$ take three different colors, there is nothing left for $d$.
If they take two different colors, all the other vertices have to take the remaining color. There are 18 possiblities for this (3 choices for the vertex with a lonely color, 3 choices for its color and 2 choices for the color of the other two, the rest is fixed, then).
If they take a single color, the other three vertices can either take the two other colors which gives again 18 by symmetry, or also have a single color, this gives 6 possibilites (3 choices for the first color, 2 choices for the second color).
18+18+6=42.