The ? 1 ? 2 ? ... ? n = k problem


Program PROBLEM.C, PROBLEM.CPP, PROBLEM.PAS

The problem
Given the following formula, one can set operators '+' or '-' instead of each '?', in order to obtain a given k:
? 1 ? 2 ? ... ? n = k
For example: to obtain k = 12 , the expression to be used will be:
- 1 + 2 + 3 + 4 + 5 + 6 - 7 = 12 with n = 7 .

The Input
Input contains a number of integers k (0<|k|<=1000000000), each on a separate line. The input ends with a zero.

The Output
For each input k, your program should print the minimal possible n (1<=n) to obtain k with the above formula.

Sample Input
12
-3646397
0

Sample Output
7
2701