func to calculate number of nodes added