Independently derived solution.
A cube has 6 faces. Exactly 4 painted faces means exactly 2 faces are glued to neighbouring cubes. In the two-cube-high stack beside the tallest stack, each cube touches the other cube vertically and the tallest stack horizontally. Each therefore has 2 unpainted faces and 4 painted faces. The tallest stack has cubes with 4, 3 and 1 glued faces from bottom to top; each of the two single-cube feet has 1 glued face. None of those qualifies. Therefore 2 cubes have exactly four painted faces. The base is painted, so touching the ground does not remove a painted face.