An abstract artist took a wooden \(5\times 5\times 5\) cube and divided each face into unit squares. He painted each square in one of three colours – black, white, and red – so that there were no horizontally or vertically adjacent squares of the same colour. What is the smallest possible number of squares the artist could have painted black following this rule? Unit squares which share a side are considered adjacent both when the squares lie on the same face and when they lie on adjacent faces.