Determining the number of balls to be added