#K3716. Maximum Children Candies Distribution

    ID: 25915 Type: Default 1000ms 256MiB

Maximum Children Candies Distribution

Maximum Children Candies Distribution

Problem Statement:

You are given a total number of candies, N. The task is to determine the maximum number of children that can receive candies if each child must receive a positive integer number of candies and the amounts are in strictly increasing order. In other words, if the first child receives 1 candy, the second 2 candies, the third 3 candies, and so on, you need to find the largest integer k such that:

$$ \frac{k(k+1)}{2} \le N $$

For example, if N = 7, the maximum number of children is 3 because 1 + 2 + 3 = 6 ≤ 7, but adding the next child (which would require 4 more candies, totaling 10) would exceed the available number of candies.

Ensure that your solution reads input from stdin and writes the output to stdout.

inputFormat

The input consists of a single line containing an integer N representing the total number of candies.

outputFormat

Output a single integer, which is the maximum number of children that can receive candies under the given conditions.

## sample
7
3

</p>