I guess we assume the cubes are the "internal ones",

since that is the number of cubes whose faces are not visible

(think of an 8x8x8 cube covered by a new layer of cubes).

If all of the cubes with "external faces" are painted, there are 2 ways to count them.

The simpler way is "the number of cubes with external faces

is the difference between the total amount of cubes and the amount of internal cubes".