eolymp
bolt
Try our new interface for solving problems
Problems

Magic constant

Magic constant

Let k be the magic constant for number n, if 1 + 2 + 3 + . . . + (k - 1) + k = n. Your task is to find the magic constant for a given number.

Input

One number n (1n1018).

Output

Print the magic constant for number n, if it exists and -1 otherwise.

Time limit 1 second
Memory limit 128 MiB
Input example #1
3
Output example #1
2
Input example #2
2
Output example #2
-1