Finding number of cubes painted