#B3687. Pocket of Integers

    ID: 11346 Type: Default 1000ms 256MiB

Pocket of Integers

Pocket of Integers

Little A has a pocket that can hold integers. He starts by placing integers in increasing order starting from \(1\) into his pocket.

However, the pocket has a capacity \(n\), which means that the sum of all the numbers placed in the pocket must not exceed \(n\). Your task is to determine the maximum number of consecutive integers starting from \(1\) that can be placed in the pocket without exceeding this capacity.

The mathematical condition is:

\(1 + 2 + 3 + \cdots + k \leq n\)

Find the maximum value of \(k\).

inputFormat

The input consists of a single integer \(n\) (\(1 \leq n \leq 10^{18}\)), representing the capacity of the pocket.

outputFormat

Output a single integer \(k\), which is the maximum count of consecutive integers starting from \(1\) that can be placed into the pocket without the sum exceeding \(n\).

sample

1
1