8 is the correct answer. Based on the given diagram above, the figure has five cubes in its front view. We can automatically count five cubes to be added to get the total number of cubes of the diagram. Next is the side view where there are six cubes in total. It does not mean that we should add all 6 to the previous five hubs but consider the shape of the first image.
The first image will only take three centers in the side view image as the two cubes are hidden in the side view. The three vertical cubes are in the first image and add the three remaining cubes on the side. The top picture shows all the cubes thus add the number of cubes you got 8.