Finding the number of candy pieces