Independently derived, agreeing with the supplied marked diagram.
Each cube has 6 faces. A face glued to another cube cannot be painted. Since the base is painted too, a cube has exactly 4 painted faces if and only if exactly 2 of its faces touch other cubes.
Inspect each cube, including the hidden supporting cubes. The qualifying cubes are the upper cube of the two-cube column at the front left, the single cube at the front middle, and the upper cube of the two-cube column behind the front-middle cube. Each touches exactly two neighbours.
The nine cubes have neighbour counts 1, 1, 2, 2, 2, 3, 3, 4 and 4. Exactly three have 2 neighbours, hence exactly three have 6 − 2 = 4 painted faces.