You have to actually count all the balls in the pyramid. Simple way is to count the balls in each level.
So lower most level lets say 1st level has 4 x 4 balls; i.e. 16 balls Similarly 2nd level has 3 x 3 balls; i.e. 9 balls. 3rd level has 2 x 2 balls; i.e. 4 balls. The top most level has just 1 ball.