Imperfect Square


Submit solution

Points: 1
Time limit: 1.0s
Memory limit: 256M

Author:
Problem type
Allowed languages
C, C++, Java, Python, Rust

Safari guide Saadan is marking out a rectangular observation area for his herd of Zebras. Obviously, squares are the optimal rectangles for this purpose, but Saadan has had it with perfectionism and perfect squares, so Saadan wants to make a rectangular observation zone with a given area with a very slightly imperfect square.

Specifically, Saadan knows his Zebras need x metres squared of grass to graze healthity. Saadan wants to know if there exists a non-negative integer n such that n(n+1) = x.

Can you let Saadan know if such an integer exists, and if so what one of them is? Otherwise, he might have to go back to the drawing board with his safari planning.

Input

The input consists of a single integer x (0 \leq x \leq 10^{18}), the desired area of Saadan's zebra pen.

Output

Output a single non-negative integer n satisfying n(n+1)=x. If one doesn't exist, output -1.

Example

Input 1
132
Output 1
11
Input 2
14
Output 2
-1
Input 3
4556
Output 3
67

Comments

There are no comments at the moment.