Jack is working on his jumping skills recently. Currently he's located at point zero of the number line. He would like to get to the point x. In order to train, he has decided that he'll first jump by only one unit, and each subsequent jump will be exactly one longer than the previous one. He can go either left or right with each jump. He wonders how many jumps he needs to reach x.

The input data consists of only one integer x ( - 109 ≤ x ≤ 109).

Output the minimal number of jumps that Jack requires to reach x.

#include<stdio.h>
#include<math.h>
int main()
{
	int  i, x, t, s;
	while(scanf("%d",&x)!=EOF)
	{
		if(x<0)
			x=-x;
		t=ceil((-1+sqrt(1+8.0*x))/2.0);
		s=t*(t+1)/2-x;
		while(s&1)
		{
			t++,s+=t;
		}
		printf("%d\n",t);
	}
	return 0;
}

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll N =1e9;
vector<ll> res;
int main(){
    res.push_back(0);
    ll a =12,b =18,sa =6,sb =8;
    res.push_back(1);
    res.push_back(3);
    res.push_back(6);
    res.push_back(10);

    for(ll i =5;i<=100000;i++){
        ll temp =i/2,v;
        if(i%2) temp++;
        if(temp&1){
            if(i&1){
                v =res[i-3]+a;
                a +=12;
            }
            else{
                v =res[i-1]+sa;
                sa +=4;
            }
        }
        else{
            if(i&1){
                v =res[i-3]+b;
                b +=12;
            }
            else{
                v =res[i-1]+sb;
                sb +=4;
            }
        }
        res.push_back(v);
        if(v>=1000000000) break;
    }
    ll x;
    scanf("%lld",&x);
    x =abs(x);
    ll ans =lower_bound(res.begin(),res.end(),x)-res.begin();
    if(x%2==0){
        ll temp =ans/2;
        if(ans%2) temp++;
        if(temp&1){
            if(ans&1) ans+=2;
            else ans ++;
        }
    }
    else{
        ll temp =ans/2;
        if(ans%2) temp++;
        if(temp%2==0){
            if(ans&1) ans+=2;
            else ans ++;
        }
    }
    printf("%lld\n",ans);
    return 0;
}

#include<stdio.h>
#include<iostream>
using namespace std;
typedef long long LL;
LL num,ans,i;
int main(){
    //freopen("1.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    while(cin>>num){
        if(num<0)num=-num;
        ans=0;
        for(i=0;;i++){
            ans=i*(i+1)/2;
            ans=ans-num;
            if(ans>=0&&ans%2==0)break;
            //if(ans<num)continue;
            //if((ans-num)%2==0)break;
        }
        cout<<i<<endl;
    }
    return 0;
}

#include <stdio.h>
#include <math.h>
int main()
{
   long long int j,k,n;
    scanf("%lld",&n);
    if(n<0)
        n=n*(-1);
    k=(-1+sqrt(1+8*n))/2;
    j=k*(k+1)/2;
    if(j==n)
        printf("%lld",k);
    else if(j<n)
    {
        k=k+1;
        j=(k*(k+1))/2;
        while((j-n)%2!=0)
        {
            k=k+1;
            j=(k*(k+1))/2;
        }
        printf("%lld",k);
    }
    else
        printf("some error");

}

#include<bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
#define vii vector<int>
#define vcc vector<char>
#define pll pair<long long, long long>
#define mem memset
#define sof sizeof
#define PB push_back
#define MP make_pair
#define TS to_string
#define F first
#define S second
#define endl '\n'
using namespace std;
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    long long a,b,c,d,e,f,i,j,k,m,n,o,x,y;
    long long ans;
    cin>>x;
    x=abs(x);
    n=sqrt(1+8*x)-1;
    n/=2;
    long long s=n*(n+1)/2;
    a=x-s;
    if(a==0) ans=n;
    else if(a%2!=n%2) n+=1;
    else{
        if(a%2==0) n+=3;
        else n+=2;
    }
    cout<<n<<"\n";
}

#include <stdio.h>

int main()
{
	int x,i,sum=0;
	scanf("%d",&x);
	if(x<0) x=-x;
	for(i=0;sum<x || (sum%2) != (x%2);sum+=i)
		i++;
	printf("%d\n",i);
	return 0;
}

#include<bits/stdc++.h>
#define int long long
using namespace std;
inline int read(){
    char c=getchar();
    int x=0;
    bool f=0;
    while(!isdigit(c))f^=!(c^45),c=getchar();
    while(isdigit(c))x=(x<<1)+(x<<3)+(c^48),c=getchar();
    if(f)x=-x;return x;
}
signed main() {
    int n=read(),ans=0;
    if(n<0) n=-n;
    for(int i=1,sum=1;n&&!ans;++i,sum+=i){
        if(sum==n||(sum>n&&!((sum-n)%2)))ans=i;
    }
    printf("%d",ans);
    return 0;
}

#include <bits/stdc++.h>
using namespace std;

int main()
{
	int n,a=0,num=0;
	cin>>n;
	n=abs(n);
	while(n>a||(n-a)%2!=0)
	{
		num++;
		a+=num;
	}
	cout<<num<<endl;

	return 0;

}

#include <stdio.h>
#include <string>
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>

using namespace std;

int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int i, x, cur = 0;
    cin >>x;
    x = abs(x);
    for (i = 1; cur < x || cur % 2 != x % 2; cur += i, i++);
    cout<<i-1;
}

#include<bits/stdc++.h>
#include <iostream>
#include<string>
using namespace std;
typedef long long int ll;

ll _sum(ll x)
{
    return ((x+1)*x)/2;
}

int main()
{
    ll n;
    cin>>n;
    n=abs(n);
    ll ans=0;
    while(_sum(ans)<n)
    {
        ans++;
    }
    while((_sum(ans)-n)%2)
        ans++;
    cout<<ans;
}

#include<cmath>
#include <cstdio>

int main()
{
    int x,ret=0,cp=0;
    scanf("%d",&x);
    if(x<0)x=-x;
    while(cp<x){
        ++ret;cp+=ret;
    }
    while((cp-x)%2!=0){
        ++ret;cp+=ret;
    }
    printf("%d\n",ret);

    return 0;
}

# include "bits/stdc++.h"
# define fp(c, k, a) for (register int c = k; c <= a; c++)
# define fq(c, k, a) for (register int c = k; c >= a; c--)
# pragma GCC optimize (2)
using namespace std;
int n, t;
inline void mn (int &a, int b) {a = a < b ? a : b;}
inline void mx (int &a, int b) {a = a > b ? a : b;}
inline void fabs (int &a) {a = a > 0 ? a : -a;}
int main () {
	scanf ("%d", &n);
	fabs (n);
	if (n == 0) {
		printf ("0");
		return 0;
	}
	fp (i, 1, 2 * n) {
		t += i;
		//printf ("%d %d\n", i, t);
		if (t == n || (t > n && ((t - n & 1) == 0))) {
			printf ("%d", i);
			break;
		}
	}
	return 0;
}

#include<bits/stdc++.h>
using namespace std;
int main()
{
    int x,ans=0;
    scanf("%d",&x);
    if(x<0) x=-x;
    for(int i=1,t=1;x&&!ans;++i,t+=i)
        if(t==x||(t>x&&!((t-x)%2)))
            ans=i;
    printf("%d",ans);
    return 0;
}

#include<cstdio>
int main()
{
    int x, ans = 0;
    scanf("%d", &x);
    if(x < 0)
        x = -x;
    for(int i=1, t=1; x && !ans; ++i, t += i)
        if(t == x || (t > x && !((t - x) % 2)))
            ans = i;
    printf("%d",ans);
    return 0;
}

#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define MAX 1000007
#define INF 1000000000000000LL
#define MOD 1000000007
#define sd(x) scanf("%d",&x)
#define sll(x) scanf("%lld",&x)
#define PB push_back
#define F first
#define S second
#define rep(i,a,b) for(int i = a; i < b; ++i)
#define dd double
#define PI 3.14159265358979323846

ll n;

int main(int argc, char const *argv[])
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin>>n;
	ll sum = 0;
	ll res = 0;
	n = abs(n);
	if(n == 0)
	{
		cout<<0<<endl;
		return 0;
	}

	for(ll i = 1; (i*i)/2 <= n; ++i)
	{
		if((i*(i+1))/2 > n)
			break;
		sum = i*(i+1)/2;
		res = i;

	}

	if(sum == n)
	{
		cout<<res<<endl;
		return 0;
	}
	if(res&1)
	{
		if((n-sum)&1)
			cout<<res+2<<endl;
		else
			cout<<res+1<<endl;
	}
	else
	{
		if((n-sum)&1)
			cout<<res+1<<endl;
		else
			cout<<res+3<<endl;
	}

	return 0;
}

#include <bits/stdc++.h>
using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int x;
  cin >> x;
  x = abs(x);
  int n = ceil((sqrt(8.0 * x + 1) - 1) / 2);
  long long temp = 1ll * (n + 1) * n / 2;
  while ((temp - x) % 2)
    temp += ++n;
  cout << n << endl;
}

#include <cstdio>
#include <algorithm>
using namespace std;
int main()
{
    int x,s;
    while(scanf("%d",&x)!=EOF){
        if(x<0) x*=-1;
        if(x==0)printf("0\n");
        else {
            s = 0;
            int n;
            for(n=0;s <= x ;)
                    s += ++n;
            if(s - n ==x){
                printf("%d\n",n-1);
                continue;
            }
            if((s-x)%2==0)printf("%d\n",n);
            else{
                if(n%2==1&&s%2==1)printf("%d\n",n+2);
                else if(n%2==0&&s%2==1)printf("%d\n",n+1);
                else if(n%2==1&&s%2==0)printf("%d\n",n+2);
                else printf("%d\n",n+1);
            }
        }
    }
    return 0;
}

#include<stdio.h>
#include<math.h>
int main(){
    long long x;
    scanf("%lld",&x);
    if(x<0)
        x=-x;
    long long ans=(sqrt(1+8*x)-1)/2;
    if((1+ans)*ans/2==x)
        printf("%lld\n",ans);
    else if(((1+ans)*ans/2+ans+1-x)%2==0)
        printf("%lld\n",ans+1);
    else if((ans+2)%2)
        printf("%lld\n",ans+2);
    else
        printf("%lld\n",ans+3);
    return 0;
}

#include <iostream>
using namespace std;

int main()
{
	long long n,ans = -1,p;
	cin >> n;
	if (n < 0)	n = -n;
	do {
		ans++;
		p = ans*(ans + 1) - 2*n;
	} while (p < 0 || p > 2*(p + 2*n) || p % 4 != 0);
	cout << ans << endl;
	return 0;
}

#include<iostream>
#include<cmath>
using namespace std;
int main()
{
	int x,y,i,t=0,s;
	cin>>y;
	x=fabs(y);
	for(i=1,s=1;x&&!t;++i,s+=i)
		if(s==x||(s>x && !((s-x)%2)))
			t=i;
	cout<<t;
	return 0;
}

#include <cstdio>
#include <algorithm>
using namespace std;

int main(){
    int x,i=0,s=0;
    scanf("%d",&x);
    if(x<0) x=-x;
    while(s<x || (s-x)%2) s+=++i;
    printf("%d\n",i);
}

#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <string>
#include <algorithm>
#include <queue>
#include <stack>
#include <map>
#include <vector>
#include <list>
#include <deque>
#include <iterator>
#include <sstream>
#define sys system("pause")
using namespace std;
const int MAXN = 100;
const int INF = 1 << 29;

int main() {
    int n;
    scanf("%d", &n);
    if (n < 0) n = -n;
    int i;
    for (i = 0; i < 46320; ++i)
        if ((1 + i) * i / 2 >= n) {
            if (((1 + i) * i / 2 - n) % 2 == 0) {
                printf("%d\n", i);
                break;
            }
        }
    return 0;
}

#include <iostream>
using namespace std;

int main() {
	int x;
	cin>>x;
	x=abs(x);
	for(int i=0; i<=100000; i++)
		if((i*(i+1)/2-x)%2==0 && i*(i+1)/2-x>=0){
			cout<<i<<endl;
			return 0;
		}
	return 0;
}

#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;
const double eps=1e-8;
int main(){
	__int64 x;
	scanf("%I64d",&x);
	if(x<0) x=-x;
	if(x<=1){
		printf("%I64d\n",x);
		return 0;
	}
	double ans=sqrt(1.0+(double)8*x)-1;
	ans/=2.0;
	if(fabs(ans-(int)ans)<eps){
		printf("%d\n",(int)ans);
		return 0;
	}
	int tans=ans;
	__int64 sum=tans*(tans+1)/2;
	if(tans%2==0){
		if((x-sum)%2==0){
			printf("%d\n",tans+3);
		}
		else printf("%d\n",tans+1);
	}
	else{
		if((x-sum)%2==0){
			printf("%d\n",tans+1);
		}
		else printf("%d\n",tans+2);
	}
	return 0;
}

#pragma comment(linker,"/STACK:50000000")
#define _CRT_SECURE_NO_WARNINGS

#include <fstream>
#include <queue>
#include <algorithm>
#include <set>
#include <iomanip>
#include <ctime>
#include <memory.h>
#include <vector>
#include <string>
#include <complex>
#include <cmath>
#include <numeric>
#include <map>
#include <cstdlib>

using namespace std;

#define sz(v) ((int)(v).size())
#define sqr(x) ((x)*(x))
const double pi = 3.1415926535897932384626433832795;
typedef pair<int,int> ii;
typedef long long ll;

#ifdef ONLINE_JUDGE
#include <iostream>
#else
ifstream cin("input.txt");
ofstream cout("output.txt");
#endif

#define int long long

__int32 main()
{
    ll x;
    cin >> x;
    if(x < 0)
        x = -x;
    int pos = 0;
    for(int len = 1; ; len++)
    {
        if(pos >= x && pos%2 == x%2)
        {
            cout << len-1;
            exit(0);
        }
        pos += len;
    }
}

#include<cmath>
#include<cstdio>
#include<iostream>
#include<algorithm>
#define ll long long
using namespace std;

int main()
{
	ll x;
	while (scanf("%lld", &x) != EOF) {
		if (x < 0) x = 0 - x;
		if (x == 0) {
			printf("0\n", 0);
			continue;
		}
		for (ll i = 0, bu = 1;; bu++) { //i为坐标，bu为当前步数
			i += bu;
			if (i == x) {
				printf("%lld\n", bu);
				break;
			}
			if (i > x) {
				if ((i - x) % 2 == 0) {
					printf("%lld\n", bu);
					break;
				}
			}

		}
	}
}

#include<iostream>
#include<cmath>
using namespace std;
long long x,ans,i;
int main(){
    cin>>x;x=abs(x);
    while(1){
        if(ans>=x&&(ans-x)%2==0)
        {
            cout<<i;
            return 0;
        }
        ans+=++i;
    }
}

 /* ..Mission 1900 soon.. */

//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse2")

#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#include<bits/stdc++.h>

using namespace std;
using namespace __gnu_pbds;

#define MOD1          998244353
#define MOD           1000000007
#define M             1000000009
#define pye           acos(-1)
#define int           long long
#define ld            long double
#define D             double
#define S             second
#define F             first
#define pb            push_back
#define ff            fflush(stdout)
#define all(c)        (c).begin(),(c).end()
#define rall(c)       (c).rbegin(),(c).rend()
#define SORT(v)       sort(ALL(v))
#define lb            lower_bound
#define ub            upper_bound
#define si(c)         (int)((c).size())
#define gcd(a,b)      __gcd(a,b)
#define lcm(a,b)      (a*(b/gcd(a,b)))
#define fast          ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define accuracy      cout << fixed << setprecision(18);
#define pow(i,n)      (ll)pow((int)i,n)
#define inputarr(a,n) for(int i=0;i<n;++i) cin>>a[i]
#define deb(x)        cout<<#x<<" "<<x<<endl;
#define debg         cout<<"I am here!"<<endl;
#define maxe(v)       *max_element(ALL(v))
#define mine(v)       *min_element(ALL(v))
#define endl          '\n'
#define tp            template
#define ty            typename
#define mem1(a)       memset(a,-1,sizeof(a))
#define mem0(a)       memset(a,0,sizeof(a))
#define bpc           __builtin_popcount
#define rep(b)    for(int i=0;i<b;i++)

const long double pi  = 3.141592653589793238463;

#ifdef magneto07
#define TRACE
#endif
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
    cout << name << " : " << arg1 << std::endl;
    //use cerr if u want to display at the bottom
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
    const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1 << " | "; __f(comma + 1, args...);
}
#else
#define trace(...) 0;
#endif

typedef vector<int>                         vi;
typedef pair<int,int>                       pii;
typedef vector<pii>                         vpi;
typedef pair<int,pii>                       pipii;
typedef vector<vector<int>>                 vvi;
typedef map<int,int>                        mp;
typedef priority_queue<pii, vector<pii>, greater<pii> > pq;
typedef tree < int ,  null_type ,  less_equal<int> ,  rb_tree_tag ,  tree_order_statistics_node_update > ordered_set;

inline  bool checkBit(int n, int i) { return n&((int)1<<i); }
inline  int setBit(int n, int i) { return n|((int)1<<i); }
inline  int resetBit(int n,int  i) { return n&(~((int)1<<i)); }
inline  void normal(int &a) { a = (a+MOD)%MOD; }
inline  int modMul(int a, int b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a*b)%MOD; }
inline  int modAdd(int a,int b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a+b)%MOD; }
inline  int modSub(int a, int b) { a %= MOD, b %= MOD; normal(a), normal(b); a -= b; normal(a); return a; }
inline  int modPow(int b, int p) { int r = 1; while(p) { if(p&1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; }
inline  int modInv(int a) { return modPow(a, MOD-2); }
inline  int modDiv(int a,int b) { return modMul(a, modInv(b)); }

inline  int fact(int r){ int ans=1;while(r)ans=modMul(ans,r),r--;return ans; }
inline  int invfact(int r){int ans=1;while(r)ans=modMul(ans,modInv(r)),r--; return ans;}
inline  D dgcd(D a,D b){ if(a<b)return dgcd(b,a); if(b<.0001)return a; return dgcd(b,fmod(a,b));}

inline int toint(const std::string &s) {std::stringstream ss; ss << s; int x; ss >> x; return x;}
inline std::string tostring(int number) {std::stringstream ss; ss << number; return ss.str();}
inline std::string tobin(int x) {return std::bitset<63>(x).to_string();}

//primes for hashing 937,991,1013,1409,1741

clock_t start;
mt19937_64 rng(chrono::system_clock::now().time_since_epoch().count());

tp<ty T1, ty T2> istream& operator>>(istream& in, pair<T1, T2> &q){
    in >> q.F >> q.S; return in;
}
tp<ty T1, ty T2> ostream& operator<<(ostream& out, pair<T1, T2> &q){
    out << q.F << " " << q.S; return out;
}
tp< ty T1, ty T2> pair<T1, T2> operator+(pair<T1, T2> p1, pair<T1, T2> p2){
    return {p1.F+p2.F, p1.S+p2.S};
}
tp< ty T1, ty T2> pair<T1, T2> operator-(pair<T1, T2> p1, pair<T1, T2> p2){
    return {p1.F-p2.F, p1.S-p2.S};
}
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    std::cerr << name << " : " << arg1 << endl;
}

template <typename Arg1, typename... Args>

void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');std::cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}

template <typename T> T allmin(T t) {return t;}

template<typename T, typename... Args> T allmin(T t, Args... args) {return min(t, allmin(args...));}

template <typename T> T allmax(T t) {return t;}

template<typename T, typename... Args> T allmax(T t, Args... args) {return max(t, allmax(args...));}

/*----------------------Graph Moves----------------------*/
// const int fx[]={+1, -1, +0, +0};
// const int fy[]={+0, +0, +1, -1};
// const int fx[]={+0, +0, +1, -1, -1, +1, -1, +1};  // Kings Move
// const int fy[]={-1, +1, +0, +0, +1, +1, -1, -1};  // Kings Move
// const int fx[]={-2, -2, -1, -1,  1,  1,  2,  2};  // Knights Move
// const int fy[]={-1,  1, -2,  2, -2,  2, -1,  1};  // Knights Move
/*-------------------------------------------------------*/

const int N=202;
const int INF=2e18;

int power( int base, int exp) {
    int res=1;
    while(exp>0) {
       if(exp%2==1) res=(res*base)%MOD;
       base=(base*base)%MOD;
       exp/=2;
    }
    return res%MOD;
}

bool isPrime(int n) {

    if (n <= 1) return false;
    if (n <= 3) return true;
    if (n % 2 == 0 || n % 3 == 0) return false;
    for (int i = 5; i * i <= n; i = i + 6)
        if (n % i == 0 || n % (i + 2) == 0)
            return false;
    return true;
}
void Timelimitexceeded()
{
   int n;
   cin>>n;
   if(n==0){
    cout<<0<<endl;
    return;
   }
   n=abs(n);
   int l=0,u=n;
   while(l<=u){
        int mid=(l+u)/2;
        if((mid*(mid+1))/2<=n)
            l=mid+1;
        else
            u=mid-1;
   }
   //cout<<l<<endl;
   if((l*(l-1))/2==n){
    cout<<(l-1)<<endl;
    return;
    }
    int ans=INF;
    for(int i=l;;i++){
        int k=(i*(i+1))/2-n;
        //cout<<k<<endl;
        if(k%2==0){
            int k1=k/2;
            cout<<i<<endl;
            return;
        }
    }
    //cout<<ans<<endl;

return;
}

signed main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int t = 1;
    clock_t start, end;
    start = clock();
    cout << fixed << setprecision(20);
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    freopen("error.txt", "w", stderr);
    #endif
    //cin>>t;
    while(t--){
        Timelimitexceeded();
    }
    end = clock();
    double time_taken = double(end - start) / double(CLOCKS_PER_SEC);
    //cerr<<time_taken;
}

#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <iostream>
using LL = long long;
int main() {
    LL x;
    std::cin >> x;
    x = std::abs(x);
    //t * (t+1) / 2 = x
    //t^2 + t - 2x = 0
    //t = (-1+sqrt(1+8x))/2
    LL t = ceil((sqrt(1+8*x)-1)/2);
    LL over = t*(t+1)/2 - x;
    while(over&1) t++, over += t;
    std::cout << t << std::endl;
    return '2'+'3'+'3'-152;
}

#include <iostream>
using namespace std;

int main() {
	int n;
	cin>>n;
	n=abs(n);
	int i;
	int sum=0;
	i=1;
	while(1)
	{

	    if(sum>=n&&(sum-n)%2==0)
	    break;
	    sum+=i;
	    i+=1;
	}
	cout<<i-1;
	return 0;
}

#include<bits/stdc++.h>
using namespace std;

/// File input & output /////
#define fRead(x)        freopen("x.txt","r",stdin)
#define fWrite(x)       freopen ("x.txt","w",stdout)

#define ld              long double
#define ll              long long
#define ull             unsigned long long
#define ff              first
#define ss              second
#define pb              push_back
#define INF             2e16
#define PI              acos(-1.0)
#define mp              make_pair
#define pii             pair<int,int>
#define pll             pair<LL,LL>

#define min3(a,b,c)     min(a,min(b,c))
#define max3(a,b,c)     max(a,max(b,c))
#define min4(a,b,c,d)   min(a,min(b,min(c,d)))
#define max4(a,b,c,d)   max(a,max(b,max(c,d)))
#define SQR(a)          ((a)*(a))
#define FOR(i,a,b)      for(int i=a;i<=b;i++)
#define ROF(i,a,b)      for(int i=a;i>=b;i--)
#define REP(i,b)        for(int i=0;i<b;i++)
#define MEM(a,x)        memset(a,x,sizeof(a))
#define ABS(x)          ((x)<0?-(x):(x))

#define SORT(v)         sort(v.begin(),v.end())
#define REV(v)          reverse(v.begin(),v.end())

#define FASTIO        ios_base::sync_with_stdio(0);cin.tie(nullptr);

///..................Sort by second element in a pair in decending order............. ///
bool SortbySecDesc(const pair<long long,long long > &a, const pair<long long,long long > &b)
{
    return a.second>b.second;
}

///.........................first element of pair in descending order..........................//////
bool sortinrev(const pair<int,int> &a,
               const pair<int,int> &b)
{
       return (a.first > b.first);
}

///.............................................................TEMPLATE................................................./////

int main()
{
    FASTIO;

    ll x;

    cin >> x;

    if(x==0)
    {
        cout << 0 << endl;
        return 0;
    }

    if(x<0)
    {
        x = x*-1;
    }

    ll p1 = 1 , ans = 0 , pos = 0;

    while(1)
    {
        if(pos < x || (pos-x) % 2 != 0)
        {
            ans++;
            pos += p1;
            p1++;

        }
        else
        {
            break;
        }
    }

    cout << ans << endl;

    return 0;
}

#include<bits/stdc++.h>
using namespace std;
int main()
{
int n,s=0,c=0,i=0;
cin>>n;
if(n==s)
cout<<i;
else
{
   n=abs(n);
    while(true)
     {
        s=s+i;
        if(s>=n && s%2==n%2)
        {cout<<i;break;}
        i++;
     }
//cout<<i;
}
return 0;
}

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define po pop_back
#define pb push_back
#define mk make_pair
#define lw lower_bound
#define up upper_bound
#define ff first
#define ss second
#define boost ios_base::sync_with_stdio(); cin.tie(0); cout.tie(0);
#define MOD 1000000007
#define MAX INT_MAX
#define MIN INT_MIN
#define rep(i,a,b) for(ll i=a;i<=b;i++)
#define per(i,a,b) for(ll i=a;i>=b;i--)
#define con continue
#define pl pair<ll,ll>
#define N 1234567
#define freopen freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
#define PI 3.14159265358979323846264338327950288419716939937510582097494459230781640628
ll a,b,c[N],d[N],c1[1234][1234],e,n,j,i,l,r,x,y,k,ans,sum;
/*
bool used[1234][1234];
ll T;
vector<ll> v1,v[N];
string s;
vector<pl> vp;
char ch[1234][1234];
pl p[1234567];
priority_queue<ll> pq;
ll dx[4]={1,-1,0,0},dy[4]={0,0,1,-1};
*/
int main(){
    cin>>n;
    if(n<0)n=-n;
    while(x < n || (n - x)%2)ans++,x+=ans;
    cout<<ans;
}

#include<bits/stdc++.h>
using namespace std;

int main()
{
	int x;
	scanf("%d",&x);
	int sum=0;
	if(x<0)
	x=-x;
	for(int i=1,j=1;x && !sum;i++,j+=i)
	{
		if(j==x || (j>x && !((j-x)%2)))
		sum=i;
	}
	printf("%d",sum);
	return 0;
}

#include <bits/stdc++.h>

#define ll long long

int main(){

    ll n;
    std::cin >> n;
    if(n == 0){
        std::cout << 0;
        return 0;
    }
    n = std::abs(n);
    ll jump(1);
    ll dis(0);
    while(true){
        dis += jump;
        if(dis >= n && (dis - n) % 2 == 0) break;
        jump++;
    }

    std::cout << jump;
    return 0;
}

#include <bits/stdc++.h>

using namespace std;
using ll        = long long;
using predicate = function<bool(int)>;

int bs(int l, int r, predicate p)
{
    while (l < r)
    {
        int m = l + (r - l) / 2;
        if (p(m))
            r = m;
        else
            l = m + 1;
    }

    return l;
}

ll psum(ll n) { return (n * (n + 1)) / 2; }

int main(void)
{
    int x;
    cin >> x;
    x = abs(x);

    int n = bs(0, 1e9 + 11, [x](ll n) { return x <= psum(n); });

    while (psum(n) % 2 != x % 2)
        ++n;

    cout << n << endl;

    return 0;
}

#include <iostream>
#include <algorithm>
#include <string>
#include <map>
using namespace std;

int main()
{
	long long n,d;
	cin>>n;
	long long t=abs(n);
	long long  k=0;
	d=1;
	long long ans,good, l=0;
	long long r=100000;
	while (l<=r)
	{
		long long	m=(l+r)/2;
		if ((m*m+m)/2<=t)
		{
			good=m;
			l=m+1;
		}
		else
		{
			r=m-1;
		}
	}
	ans=good;
	k=t-(good*good+good)/2; good++;
	d=(good*good+good)/2-t;
	if (k!=0)
	{
		ans++;
	while (d%2!=0)
	{
		ans++;
		good++;
		d=(good*good+good)/2-t;
	}
	}

//	if (k!=0)
//	if (d%2!=0) ans+=(k*2); else ans++;

	cout<<ans<<endl;
}

/*
 * 11b.cpp
 *
 *  Created on: Jun 27, 2020
 *      Author: Stanley
 */

#include <iostream>
#include <algorithm>
#include <cassert>
#include <queue>
#include <set>
#include <string>
#include <vector>
#include <map>
#include <deque>
#include <cctype>
#include <climits>
#include <cmath>
#include <cstdlib>
#include <iomanip>
#include <utility>
#include <bitset>
#include <forward_list>
#include <list>
#include <stack>
#include <sstream>
#include <unordered_map>
#include <unordered_set>

using namespace std;

#define PF push_front
#define PB push_back
#define INS insert

#define FI first
#define SE second
#define all(obj) begin(obj), end(obj)
#define rall(obj) (obj).rbegin(), (obj).rend()

#define LB lower_bound
#define UB upper_bound

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<set<int> > vsi;

typedef unsigned long long ull;
typedef pair<int,bool> pib;
typedef pair<ll,bool> plb;
typedef vector<vector<int> > vvi;
typedef vector<set<pii> > vspi;
typedef vector<vector<pii> > vvpi;
typedef map<int,int> mii;
typedef map<ll,ll> mll;
typedef map<char, int> mci;
typedef map<string,int> msi;
typedef map<string,string> mss;

ll gcd(ll a, ll b) {return b ? gcd(b, a%b) : a;}

template <class T1,class T2> struct cmpf {
	bool rev;
	inline bool operator()(const pair<T1,T2>& a, const pair<T1,T2>& b) const {return (a.first<b.first)^rev;}
	cmpf(bool b=false) {rev=b;}
};
template <class T1,class T2> struct cmps {
	bool rev;
	inline bool operator()(const pair<T1,T2>& a, const pair<T1,T2>& b) const {return (a.second<b.second)^rev;}
	cmps(bool b=false) {rev=b;}
};

string to_string(const char& c){return string(1, c);}
string to_string(const string& s){return '"'+s+'"';}
string to_string(const char* s){return to_string((string)s);}
string to_string(const bool& b){return (b?"true":"false");}
string to_string(const vector<bool>& v,const string& sep=" ") {
	string s = "[";
	for (int i=0; i<v.size(); i++) {if (i){s += sep;} s += to_string(v[i]);}
	return s + "]";
}
template <size_t N> string to_string(const bitset<N>& v) {
	string s = "[";
	for (size_t i=0; i<N; i++) s += v[i] ? '1' : '0';
	return s + "]";
}
template <class T1,class T2> string to_string(const pair<T1, T2>& p, const string& sep=",");
template <class T> string to_string(const T& v, const string& sep=" ") {
	bool first = true; string s = "{";
	for (const auto &x: v) {
		if (!first) s += sep;
		else first = false;
		s += to_string(x);
	}
	return s + "}";
}
template <class T> string to_string(const T& v, const int& sz, const string& sep=" ") {
	string s = "[";
	for (int i=0; i<sz; i++) {if (i){s += sep;} s += to_string(v[i]);}
	return s + "]";
}
template <class T1,class T2> string to_string(const pair<T1,T2>& p, const string& sep) {return "(" + to_string(p.first) + sep + to_string(p.second) + ")";}

#define debug(obj) cout << #obj << ": " << to_string(obj) << endl;
#define debug1(obj, sz) cout << #obj << ": " << to_string(obj, sz) << endl;
#define debug2(obj, sz1, sz2) cout << "-----" << #obj << "-----\n"; for (int i=0; i<sz1; i++) cout << to_string(obj[i], sz2) << " "; cout << endl;
#define debug3(obj, sz1, sz2, sz3) cout << "-----" << #obj << "-----\n"; for (int i=0; i<sz1; i++) {for (int j=0; j<sz2; j++) cout << to_string(obj[i][j], sz3) << " "; cout << endl;} cout << endl;

ll binpow(const ll& x, const ll& p, const ll& mod) {assert(mod>0);
	if (p == 0) return 1;
	if (p == 1) return x % mod;
	if (p & 1) return (binpow((x*x) % mod, p/2, mod) * x) % mod;
	return binpow((x*x) % mod, p/2, mod) % mod;
}

template <class T> void chmn(T& a, const T& b) {if (a>b) a=b;}
template <class T> void chmx(T& a, const T& b) {if (a<b) a=b;}

void setIO() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr); cout.tie(nullptr);
}

int chr[8] = {-1, 0, 1, 0, -1, -1, 1, 1};
int chc[8] = {0, 1, 0, -1, -1, 1, -1, 1};

const ll MOD = 1e9+7; // 998244353;
const int INIT = 1001001001;
const int MN = -1;

//int A[MN];
void solve() {
	ll X;
	cin >> X;

	if (X < 0) X = -X;

	ll cur = 0, jumps = 0;
	while (cur < X) {
		cur += ++jumps;
	}

	while ((cur - X) & 1) {
		cur += ++jumps;
	}

	cout << jumps << endl;
}

int main() {
	setIO();

	ll T = 1;
//	cin >> T;

	while (T--) solve();

	return 0;
}

//by rko27
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define int  long long
#define ll  long long
int mod=1000000000+7;
#define pb push_back
#define mp make_pair
ll power(ll x,ll y)
{
	ll res=1;
	x=x;
	while(y>0)
	{
		if(y&1)res=(res*x);
		y=y>>1;
		x=(x*x);
	}
	return res;
}
ll powe(ll x, ll y)
{
	x = x%mod, y=y%(mod-1);
	ll ans = 1;
	while(y>0)
	{
		if (y&1){ans = (1ll * x * ans)%mod;}
		y>>=1;
		x = (1ll * x * x)%mod;
	}
	return ans;
}
void fun()
{
	#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#endif
	//786
}
bool isPrime(int n)
{
	for(int i=2;i*i<=n;i++)
		if(n%i==0) return false;
	return true;
}
ll ncr(ll n,ll r)
{
	ll res=1;
	if(r>n)
		return 0;
	if(r>n-r)
		r=n-r;
	for(ll i=0;i<r;i++)
	{
		res*=(n-i);
		res/=(i+1);
	}
	return res;
}
signed main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	//rko;
	fun();
	int ttt=1; //cin>>ttt;
	while(ttt--)
	{
		int n; cin>>n;
		n=abs(n);
		int x=0;
		int i=1;
		while(x<n or (x-n)&1)
		{
			x+=i;
			i++;
		}
		cout<<i-1;
	}
	return 0;
}

#include<bits/stdc++.h>
int main()
{
    int tp,x,ans;
    while(~scanf("%d",&x))
    {
        x=x<0?-x:x,ans=ceil((-1+sqrt(1+8.0*x))/2),tp=ans*(ans+1)/2-x;
        while(tp&1) ans++,tp+=ans;
        printf("%d\n",ans);
    }
    return 0;
}

#include<stdio.h>
int main()
{
  int x,sum,i;
  while(scanf("%d",&x)!=EOF)
  {
	  if(x==0) printf("0\n");
	  else
	  {
		if(x<0) x=-x;
        sum=0;
	    for(i=1;i<=x;i++)
		{
	      sum+=i;
	      if(sum>=x) break;
		}
	    if(sum==x) printf("%d\n",i);
	    else
		{
	       if((sum-x)%2==0) printf("%d\n",i);
		   else
		   {

			   if((x-sum+i)%2==0)
				  printf("%d\n",i+2);
			   else
				   printf("%d\n",i+1);
		   }
		}
	  }
  }
  return 0;
}

#include <iostream>
#include <queue>
#include <cmath>
#include <set>

using namespace std;

#define INF 2147483647
#define EL cout<<endl
#define TI freopen("test.inp","rt",stdin)

#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define FORD(i,a,b) for(int i=a;i>=b;i--)
#define REP(i,n) for(int i=0;i<n;i++)

int INP;
#define BUFSIZE (1<<10)
char BUF[BUFSIZE+1], *inp=BUF;
#define GETCHAR(INP) {              \
    if(!*inp) {                 \
        fread(BUF,1,BUFSIZE,stdin); \
        inp=BUF;                \
    }                       \
    INP=*inp++;                 \
}
#define DIG(a) (((a)>='0')&&((a)<='9'))
#define GN(j) {                 \
    GETCHAR(INP); while(!DIG(INP)) GETCHAR(INP);\
    j=INP-'0'; GETCHAR(INP);                \
    while(DIG(INP)){j=10*j+(INP-'0');GETCHAR(INP);} \
}

queue<int> q;
long long N,M;
void xuly()
{
     cin>>N;
     if (N<0) N=-N;
     M=sqrt(2*N);

     while (M*(M+1)<2*N) M++;
     while ((M*(M+1)/2-N)%2) M++;
     cout<<M<<endl;

//     M++;
//     assert(M*(M+1)/2>=N+4 && M*(M+1)/2<=N+2*(M-1));

}

int main()
{
//    TI;
    xuly();

    return 0;
}

#include<iostream>
using namespace std;
long long x,sum=0;
int main(){

    while(cin>>x){
		int i=0;
		sum=0;
        if(x<0)
            x=-1*x;
        while(sum<x || (sum-x)%2){
            i++;
            sum+=i;
        }
        cout<<i<<endl;
    }
    return 0;
}

#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
using namespace std;

typedef long long INT;

bool check( INT y, INT t ) {
    for ( int i = t; i >= 1; i-- ) {
        if ( y - 2 * i >= 0 ) {
            y -= 2 * i;
        }
    }
    return y == 0;
}

INT solve( INT x ) {
    INT t = 0;
    INT y = 0;
    while ( y < x ) {
        t++;
        y += t;
    }
    while ( !check( abs( x - y ), t ) ) {
        t++;
        y += t;
    }
    return t;
}

int main() {
    INT x;
    while ( cin >> x ) {
        cout << solve( abs( x ) ) << endl;
    }
    return 0;
}

#include<iostream>

using namespace std;

int main(){
    long long n;
    long long sum, ans, p;
	long long a;
	scanf("%lld", &n);
    if(n < 0) n = -n;
	sum = ans = 0;
	for(p = 1; sum < n;p++, ans++){
		sum += p;
	}
    a = sum - n;
    if(n == 0) printf("0");
    else if(a % 2 == 0) printf("%lld", ans);
    else if((a + p) % 2 == 0) printf("%lld", ans + 1);
    else printf("%lld\n", ans + 2);
    return 0;
}

#include <bits/stdc++.h>
using namespace std;

int main()
{
    ios::sync_with_stdio(0);
    long long x,ats=0;
    cin>>x;
    x=abs(x);

    while(ats*(ats+1) < 2*x)ats++;

    while((ats*(ats+1)/2)%2 != (x)%2)ats++;

    cout<<ats<<"\n";
}

#include <cstdio>
#include <iostream>
#include <fstream>
#include <sstream>
#include <stdlib.h>
#include <algorithm>
#include <string>
#include <vector>
#include <unordered_map>
#include <map>
#include <set>
#include <math.h>
#define M_PI    3.14159265358979323846  /* pi */
#define ri(i) int i;scanf("%d",&i);
#define rii(i,j) int i,j;scanf("%d%d",&i,&j);
#define rc(i) char i;cin>>i;
#define rll(i) long long i;cin>>i;
#define ff(i,s,n) for(int i=(s);i<(n);i++)
#define fr(i,s,n) for(int i=(n-1);i>=(s);i--)
#define FF(i,s,n) for(int i=(s);i<=(n);i++)
#define Fr(i,s,n) for(int i=(n);i>=(s);i--)
#define mp(a,b) make_pair(a,b)

template<typename T, typename U> inline void swap(T &a, U &b) {
    a = a^b;
    b = a^b;
    a = a^b;
}

inline void swap(int &a, int &b) {
    a = a^b;
    b = a^b;
    a = a^b;
}

inline void swap(long long &a, long long &b) {
    a = a^b;
    b = a^b;
    a = a^b;
}

template<typename T, typename U> inline void smax(T &a, U b) {
    if (b > a)a = b;
}

template<typename T, typename U> inline void smin(T &a, U b) {
    if (b < a)a = b;
}

inline int gcd(int a, int b) {
    if (a < b)swap(a, b);
    while (b > 0) {
        a %= b;
        swap(a, b);
    }
    return a;
}

long long nchose(int a, int b) {
    long long ans = 1;
    smax(a, b - a);
    int p = 2;

    FF(i, b - a + 1, b) {
        ans *= (long long) i;
        while (p <= a && ans % p == 0)ans /= p++;
    }
    return ans;
}

using namespace std;
static int MOD = 1073741824;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vll > vvll;
typedef pair<vi, vi> pvi;
typedef vector<vi > vvi;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<pair<string, string> > vpss;
typedef vector<pii > vpii;
typedef vector<pll > vpll;
typedef vector<vpii > vvpii;
typedef map<int, int> mii;
typedef unordered_map<int, int> imap;
typedef unordered_map<ll, ll> lmap;

int n,j,tot;
int main() {
    cin>>n;n=abs(n);
    while(n>0){
        n-=++j;
    }
    n=-n;
    if(n%2==0){
        cout<<j;
    }else if(j%2==1){
        cout<<j+2;
    }else cout<<j+1;
}

#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <cmath>
#include <ctime>

#include <string>
#include <sstream>
#include <algorithm>
#include <iostream>
#include <vector>
#include <list>
#include <set>
#include <map>

using namespace std;

#ifdef ILIKEGENTOO
#define Eo(x) { cerr << #x << " = " << (x) << endl; }
#define E(x) { cerr << #x << " = " << (x) << "   "; }
#else
#define Eo(x)
#define E(x)
#endif
#if defined ILIKEGENTOO || !(defined __GNUC__ ) || (__GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 6))
template<typename T, size_t N> struct array { T val[N]; T& operator[](size_t n) { if(n >= N) assert(false); return val[n]; } T* begin() { return &val[0]; } T* end() { return &val[0]+N; } };
#else
#include <array>
#endif
#define EO(x) Eo(x)
#define Sz(x) (int((x).size()))
#define All(x) (x).begin(),(x).end()

template<typename A, typename B> ostream& operator<<(ostream& os, const pair<A, B>& p) { return os << '(' << p.first << ", " << p.second << ')'; }

typedef double real;
typedef long long int64;
typedef unsigned long long uint64;
typedef pair<int, int> pip;

const int inf = 0x3f3f3f3f;
const int64 inf64 = 0x3f3f3f3f3f3f3f3fLL;
const real eps = 1e-8;

int main() {
	ios_base::sync_with_stdio(false);
	int64 x; cin >> x;
	if(x < 0) x = -x;

	int64 n = 0;
	int64 sum = 0;
	while(x != sum) {
        n++;
        sum += n;
        if(sum == x) break;
        if(sum > x && (sum - x) % 2 == 0) break;
	}
	cout << n << endl;

	return 0;
}

#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll x;
    cin>>x;
    if(x<0)
        x=-x;
    ll p=0;
    while(p*(p+1)/2<x)
    {
        p++;
    }
    ll diff=p*(p+1)/2-x;
    if(diff%2==1)
        p++;
    diff=p*(p+1)/2-x;
    if(diff%2==1)
        p++;
    diff=p*(p+1)/2-x;
    if(diff%2==1)
        p++;
    cout<<p;
    return 0;
}

#include<stdio.h>

int main()
{
    int n;
    scanf("%d",&n);
    if(n==0)
    {
        printf("0\n");
        return 0;
    }
    if(n<0)n=-n;
    int i;
    for(i=1;i<99999;i++)
    {
        __int64 all=(i+1)*i/2;
        if(all==n)
        {
            printf("%d\n",i);
            break;
        }
        else if(all>n)
        {
            if(i%2==0)
            {
                if((all-n)%2==0)
                    printf("%d\n",i);
                else
                    printf("%d\n",i+1);
            }
            else
            {
                if((all-n)%2==0)
                    printf("%d\n",i);
                else
                    printf("%d\n",i+2);
            }

            break;
        }
    }
    return 0;
}

/*************************************************************************
	> File Name: CF11B.cpp
	> Author: Staryui
	> Mail: poi7521@sina.cn
	> Created Time: 一 10/ 7 11:30:49 2019
 ************************************************************************/

#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<cmath>
#include<map>
#include<list>
#include<algorithm>
#include<vector>
#include<set>
#include<cstring>
#include<stack>
#include<queue>
#include<stdlib.h>
using namespace std;
int main() {
    int x,ans=0;
    scanf("%d",&x);
    if(x<0) x=-x;
    for(int i=1,t=1;x&&!ans;++i,t+=i)
        if(t==x||(t>x&&!((t-x)%2)))
            ans=i;
    printf("%d",ans);
    return 0;
}

#include <bits/stdc++.h>
using namespace std;
int main()
{
	int x,ans=0;
	cin>>x;
	if(x<0)
	{
		x=-x;
	}
	for(int i=1,t=1; x&&!ans; ++i,t+=i)
	{
		if(t==x||(t>x&&!((t-x)%2)))
		{
			ans=i;
		}
	}
	cout<<ans;
	return 0;
}
////

#include <iostream>
#include <queue>
using namespace std;
long long n;
int DP[30010];
queue <int> q;
int main ()
{

	cin >> n;
	if (n < 0) n= -n;
	long long i = 0;
	/*
	int k, j;
	for (i = 0; i< 20; i ++)
		for (j = 0 ; j < (1 << i) ; j ++)
	{
		int ret = 0;
		for (k = 0; k < i; k ++) if (j& ( 1 << k)) ret += k+1; else ret -= k+1;
		if (ret == n) {cout << i << endl; return 0;}
	}
	*/
	i = 0;
	while ( 1)
	{
		long long p = (i * (i+1)) / 2;
		if (p >= n && p%2 == n%2) break;
		i ++;
	}
	cout << i << endl;
	return 0;
}

#include <stdio.h>
#include <math.h>

int main()
{
	int n, res, sum, isOdd;
	scanf("%d", &n);

	if (n < 0)
		n = -n;
	res = (int)(sqrt(n * 2));

	sum = res * (res + 1);
	while (sum < n * 2)
	{
		res++;
		sum += res * 2;
	}

	isOdd = (n & 0x01) * 2;

	while((sum & 0x02) != isOdd)
	{
		res++;
		sum += res * 2;
	}
	printf("%d\n", res);

	return 0;
}

#include<iostream>
#include<utility>
#include<algorithm>
#include<set>
#include<vector>
#include<map>
#include<iterator>
#include<functional>
#include<iomanip>
#include<deque>
#include<queue>
#include<stack>
#include<cstring>

#define ll long long
#define pii pair<int,int>
#define REP(i,n) for(ll i=0;i<n;i++)
#define IREP(in,i,n) for(ll i=in;i<n;i++)

#define dbg(msg) //cout << msg << endl;
#define var(n,x) //cout << n << " = " << x << endl;

using namespace std;

int pj=0;

typedef set<pii> mqueue;

int main(int argv, char** argc){

  ll x;
  cin >> x;

  x = abs(x);

  vector<ll> summa;
  summa.push_back(0);

  while(true){
    ll last = summa[summa.size() -1 ];
    var("last", last);
    if( last == x ){
      break;
    }

    if( last > x ){
      ll diff = last - x;
      var("diff", diff);
      if( diff % 2 == 0 ){
        diff /= 2; // because it kinda fold
        bool found = false;
        for(ll i = summa.size() - 2; i > 0; i--){
          ll idiff = 1;
          ll cdiff = summa[i] - summa[i-idiff];
          while(cdiff < diff && i-idiff >=0 ){
            idiff ++ ;
            cdiff = summa[i] - summa[i-idiff];
          }
          if( cdiff == diff ){
            found = true;
            break;
          }
        }
        if( found ) break;
      }
    }

    summa.push_back(last+summa.size());
  }

  cout << summa.size()-1 << endl;

  return 0;
}

#include<stdio.h>
#include<math.h>
int main()
{
    int inp;
    int ans;
    int sum;
    scanf("%d",&inp);
    inp=inp>0?inp:-inp;
    if(inp)
    {
        ans=(int)sqrt(2*inp);
        sum=ans*(ans+1)/2;
        if(sum==inp)
        {
            printf("%d\n",ans);
            return 0;
        }
        if(sum>inp)ans--;
        sum=(ans+1)*(ans+2)/2;
        if((sum-inp)%2)
        {
            if(ans%2)ans+=2;
            else ans+=3;
        }
        else ans+=1;
        printf("%d\n",ans);

    }
    else printf("0\n");
    return 0;
}

#include<iostream>
using namespace std;
long long x,sum=0;
int main(){
    while(cin>>x){
		int i=0;
		sum=0;
        if(x<0)
            x=-1*x;
        while(sum<x || (sum-x)%2){
            i++;
            sum+=i;
        }
        cout<<i<<endl;
    }
    return 0;
}

#include<stdio.h>
int main()
{
    int n,i,s;
    scanf("%d",&n);
    s=0;
    if(n<0) n=-n;
    for(i=0;;i++)
    {
        s=s+i;
        if(s==n||(s>n&&(s-n)%2==0))
        {
            printf("%d",i);
            break;
        }
    }
    return 0;
}

#include <iostream>
using namespace std;

int countJumps(long n)
{
  n=abs(n);
  long sum=0,step=0;
  while(sum<n||(sum-n)%2!=0)
  {
    step++;
    sum+=step;
  }
  return step;
}

int main() {
  long n;
  cin>>n;
  cout<<countJumps(n);
  return 0;
}

#include<bits/stdc++.h>
using namespace std;
int n,ans=0;
int main() {
    cin>>n;
    n=n<0?-n:n;
    for(int i=1,t=1;n&&!ans;i++,t+=i)
        if((t==n)||(t>n&&!((t-n)%2>0)))
            ans=i;
    cout<<ans<<endl;
    return 0;
}

#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <utility>
#include <vector>
#include <map>
#include <set>
#include <bitset>
#include <queue>

using namespace std;

using ll = long long;
using ld = long double;
constexpr ll MAX = 1e9;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);

    ll x;
    cin >> x;
    x = abs(x);
    ll p = 0;
    ll steps = 0;
    while (p < x) {
        ++steps;
        p += steps;
    }

    // printf("%lld %lld\n", p, x);
    if (p == x) {
        cout << steps << '\n';
    } else {
        while ((p - x) & 1) {
            ++steps;
            p += steps;
        }

        cout << steps << '\n';
    }

    return 0;
}

#include <cstdlib>
#include <cstdarg>
#include <cassert>
#include <cctype> // tolower
#include <ctime>
#include <cmath>
#include <tuple>

#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <stdexcept>

#include <map>
#include <unordered_map>
#include <set>
#include <list>
#include <stack>
#include <queue>
#include <vector>
#include <string>

#include <limits>
#include <utility>
#include <memory>

#include <numeric>
#include <iterator>
#include <algorithm>
#include <functional>

/*
 * g++ -g -std=c++11 -DBUG -D_GLIBCXX_DEBUG -Wall -Wfatal-errors -o cforce{,.cpp}
 *
 * TODO:
 *      C++ dataframe
 *      stl11 -> c++11 standard template lib in c++98
 *      overload >> for map and set, using (insert) iterator
 *      chmod:: consider an algorithm stable to int64 overflow
 *      shortest path algorithm
 *      shortest path in a tree
 *      maximum network flow
 *      partial idx/iter sort
 *      a prime number generator which traverses prime numbers w/ ++
 *      a divisor generator which traverses divisors efficiently
 *      Apply1st ?!
 *      Apply2nd and bind2nd ?!
 *          count_if ( a.begin(), a.end(), a.second < x )
 *      Arbitrary-precision arithmetic / Big Integer / Fraction - rational num
 *      tuple class --> cplusplus.com/reference/tuple
 *      get<1>, get<2>, bind2nd ( foo ( get<2> pair ), val )
 *      isin( const T & val, first, last )
 *      fuinction composition in c++
 *          blogea.bureau14.fr/index.php/2012/11/function-composition-in-c11/
 *          cpp-next.com/archive/2010/11/expressive-c-fun-with-function-composition/
 *      TimeWrapper -- accumulate time of a function call
 *          stackoverflow.com/questions/879408
 *      hash map -- possible hash value & obj % some_big_prime [ b272 ]
 *          lower level can be a simple map to resolve hash collisions
 *      add explicit everywhere necessary
 *      bloom filters
 *      heap -> how to update values in place / increase-key or decrease-key ... IterHeap ?!
 *      median maintaince --> max_heap / min_heap
 *      prim's min spaning tree alg. O ( m log n ) using heap contianing V - X vertices
 *      kruskal algorithm minimum cost spanning tree with union find data structure
 *      unique_ptr
 *      hufman codes
 *      simple arithmatic tests
 *      longest common subsequence using seq. alignment type algorithm
 *      longest common substring ( consequative subsequeance )
 *      Graham scan; en.wikipedia.org/wiki/Graham_scan
 *      problem/120/F -- how to extend in order to calculate all-pair distances in a tree
 *      compile time prime number calculator using templates
 *      swith to type_cast < T1, T2 > for val2str & str2val
 *      overload plus<> for two vectors?!
 *      overloading operator << for std::tuple:
 *          stackoverflow.com/questions/9247723
 */

/*
 * @recepies
 * ----------------------------------------------
 * odd / even
 *      transform ( x.begin(), x.end(), x.begin(), bind2nd( modulus<int>(), 2 ));
 *      count_if ( x.begin(), x.end(), bind2nd( modulus < int > (), 2));
 * Apply2nd
 *      max_element ( m.begin(), m.end(), Apply2nd < string, int , less < int > > )
 *      sort ( a.begin(), a.end(), Apply2nd < char, int , greater< int > > )
 *      count_if ( m.begin(), m.end(), Apply2nd < string, int, modulus < int > > )
 *      accumulate ( m.begin(), m.end(), 0.0, Apply2nd < int, double, plus < double > > )
 *      accumulate ( m.begin( ), m.end( ), pair < int, double> ( 0 , 0.0 ) , operator+ < int, double > )
 * abs_diff
 *      adjacent_difference ( a.begin(), a.end(), adj_diff.begin( ), abs_diff < int > ( ) )
 *      accumulate ( a.begin(), a.end(), 0, abs_diff < int > ( ) )
 * erase
 *      a.erase ( remove_if ( a.begin( ), a.end( ), bind2nd ( less < int >( ), 0 ) ), a.end( ) )
 *      a.erase ( remove ( a.begin( ), a.end( ), b.begin( ), b.end( ) ), a.end ( ) )
 * binding
 *      bind2nd ( mem_fun_ref (& ClassName::m_func ), arg )  // binds the argument of the object
 * iterator generators
 *      generate_n ( back_inserter ( a ), n, rand );  // calls push_back
 *      generate_n ( inserter( a, a.begin( ) + 5 ), 10, RandInt( 0 , 100 ) )  // calls insert
 *      copy ( foo.begin( ), foo.end( ), insert_iterator < std::list < double > > ( bar, bar.begin( ) + 5 ))
 * copy ( a.begin( ), a.end( ), ostream_iterator < double > ( cout, ", " ))
 * accumulate ( m.begin( ), m.end( ), pair < int, double> ( 0 , 0.0 ) , operator+ < int, double > )
 * transform (numbers.begin(), numbers.end(), lengths.begin(), mem_fun_ref(&string::length));
 */

/*
 * @good read
 * ----------------------------------------------
 *  [ partial ] template specialization
 *      cprogramming.com/tutorial/template_specialization.html
 *  function composition
 *      cpp-next.com/archive/2010/11/expressive-c-fun-with-function-composition
 */

/*
 * @prob set
 * ----------------------------------------------
 *  purification --> c330
 */

/*
 * @limits
 * ----------------------------------------------
 * int                  31    2.14e+09
 * long int             31    2.14e+09
 * unsigned             32    4.29e+09
 * long unsigned        32    4.29e+09
 * size_t               32    4.29e+09
 * long long int        63    9.22e+18
 * long long unsigned   64    1.84e+19
 */

/*
 * issues
 * ----------------------------------------------
 * stackoverflow.com/questions/10281809
 * mem_fun -> func_obj ( pointer to instance, origanal argument )
 * bind1st ( mem_fun ( & ClassName::m_func ), this )    // binds obj of the class
 * bind1st takes 'const T &' as the first argument
 */

/*
 *  typedef / define
 * ----------------------------------------------
 */

typedef          long long int  int64;
typedef unsigned long long int uint64;

#define DOUBLE_INF std::numeric_limits< double >::infinity()
#define DOUBLE_NAN std::numeric_limits< double >::quiet_NaN()

#define __STR__(a) #a
#define STR(a) __STR__(a)

#define ASSERT(expr, msg) \
    if (!( expr )) \
        throw std::runtime_error(__FILE__ ":" STR(__LINE__) " - " msg);

#define DECLARE( X ) \
    typedef       std::shared_ptr < X >  X ## _shared_ptr; \
    typedef const std::shared_ptr < X >  X ## _const_shared_ptr;

#ifdef BUG
    #define DEBUG(var) { std::cout << #var << ": " << (var) << std::endl; }
    #define COND_DEBUG(expr, var) if (expr) \
        { std::cout << #var << ": " << (var) << std::endl; }
    #define EXPECT(expr) if ( ! (expr) ) std::cerr << "Assertion " \
        << #expr " failed at " << __FILE__ << ":" << __LINE__ << std::endl;
#else
    #define DEBUG(var)
    #define COND_DEBUG(expr, var)
    #define EXPECT(expr)
#endif

#define DBG(v) std::copy( v.begin(), v.end(), std::ostream_iterator < typeof( *v.begin() )> ( std::cout, " " ) )

#if __cplusplus < 201100
    #define move( var ) var
#endif

/*
 * http://rootdirectory.de/wiki/SSTR()
 * usage:
 *      SSTR( "x^2: " << x*x )
 */
#define SSTR( val ) dynamic_cast< std::ostringstream & >( std::ostringstream() << std::dec << val ).str()

/* https://www.quora.com/C++-programming-language/What-are-some-cool-C++-tricks */
// template <typename T, size_t N>
// char (&ArraySizeHelper(T (&array)[N]))[N];
// #define arraysize(array) (sizeof(ArraySizeHelper(array)))

/*
 * forward decleration
 * ----------------------------------------------
 */
class ScopeTimer;

/*
 *  functional utils
 * ----------------------------------------------
 */

template < typename T >
struct abs_diff : std::binary_function < T, T, T >
{
    typedef T value_type;

    inline value_type operator( ) ( const value_type & x, const value_type & y ) const
    {
        return std::abs( x - y );
    }
};

// template < class InputIterator, class T >
// class isin : public std::binary_function < InputIterator, InputIterator, bool >
// {
//     public:
//         typedef T value_type;
//
//         isin ( const InputIterator & first, const InputIterator & last ):
//             m_first ( first ), m_last ( last ) { }
//
//         bool operator ( ) ( const value_type & val ) const
//         {
//             return std::find ( m_first, m_last, val ) != m_last;
//         }
//     private:
//         const InputIterator m_first, m_last;
// }

template < typename value_type, typename cont_type >
class isin : public std::unary_function < value_type, bool >
{
    public:
        isin( const cont_type & vals ): m_vals ( vals ) { };

        bool operator ( ) ( const value_type & x ) const
        {
            return std::find ( m_vals.begin( ), m_vals.end( ), x ) != m_vals.end( );
        }

    private:
        const cont_type m_vals;
};

/*
 * max_element, min_element, count_if ... on the 2nd element
 * eg: max_element ( m.begin(), m.end(), Apply2nd < string, int , less < int > > )
 */
template < class T1, class T2, class BinaryOperation >
class Apply2nd : std::binary_function < typename std::pair < T1, T2 >,
                                        typename std::pair < T1, T2 >,
                                        typename BinaryOperation::result_type >
{
    public:
        typedef T1 first_type;
        typedef T2 second_type;

        typedef typename BinaryOperation::result_type result_type;
        typedef typename std::pair < first_type, second_type > value_type;

        inline result_type operator( ) ( const value_type & x, const value_type & y ) const
        {
            return binary_op ( x.second , y.second );
        }
    private:
        BinaryOperation binary_op;
};

/*
 * algo utils
 * ----------------------------------------------
 */

/**
 * count the number of inversions in a permutation; i.e. how many
 * times two adjacent elements need to be swaped to sort the list;
 * 3 5 2 4 1  -->  7
 */
template < class InputIterator >
typename std::iterator_traits<InputIterator>::difference_type
count_inv ( InputIterator first, InputIterator last )
{
    typedef typename std::iterator_traits<InputIterator>::difference_type difference_type;
    typedef typename std::iterator_traits<InputIterator>::value_type value_type;

    std::list < value_type > l; /* list of sorted values */
    difference_type cnt = 0;

    for ( difference_type n = 0; first != last; ++first, ++n )
    {
        /* count how many elements larger than *first appear before *first */
        typename std::list < value_type >::iterator iter = l.begin( );
        cnt += n;

        for ( ; iter != l.end( ) && * iter <= * first; ++ iter, -- cnt )
            ;
        l.insert( iter, * first );
    }

    return cnt;
}

template < class ForwardIterator, class T >
inline void fill_inc_seq ( ForwardIterator first, ForwardIterator last, T val )
{
    for ( ; first != last; ++first, ++val )
        * first = val;
}

template <class ForwardIterator, class InputIterator >
ForwardIterator remove ( ForwardIterator first, ForwardIterator last, InputIterator begin, InputIterator end )
{
    ForwardIterator result = first;

    for ( ; first != last; ++ first )
        if ( find ( begin, end, *first ) == end )
        {
            *result = *first;
            ++result;
        }

    return result;
}

/* stackoverflow.com/questions/1577475 */
template < class RAIter, class Compare >
class ArgSortComp
{
    public:
        ArgSortComp ( const RAIter & first, Compare comp ):  m_first ( first ), m_comp( comp ) { }
        inline bool operator() ( const size_t & i, const size_t & j ) const
        {
            return m_comp (  m_first[ i ] ,  m_first[ j ] );
        }
    private:
        const RAIter & m_first;
        const Compare m_comp;
};

/*!
 * usage:
 *      vector < size_t > idx;
 *      argsort ( a.begin( ), a.end( ), idx, less < Type > ( ) );
 */
template < class RAIter, class Compare=std::less< typename RAIter::value_type > >
void argsort( const RAIter & first,
              const RAIter & last,
              std::vector < size_t > & idx,
              Compare comp = Compare()) // std::less< typename RAIter::value_type >() )
{
    const size_t n = last - first;
    idx.resize ( n );

    for ( size_t j = 0; j < n; ++ j )
        idx[ j ] = j ;

    std::stable_sort( idx.begin(), idx.end(), ArgSortComp< RAIter, Compare >( first, comp ));
}

template < class RAIter, class Compare >
class IterSortComp
{
    public:
        IterSortComp ( Compare comp ): m_comp ( comp ) { }
        inline bool operator( ) ( const RAIter & i, const RAIter & j ) const
        {
            return m_comp ( * i, * j );
        }
    private:
        const Compare m_comp;
};

/*!
 * usage:
 *      vector < list < Type >::const_iterator > idx;
 *      itersort ( a.begin( ), a.end( ), idx, less < Type > ( ) );
 */
template <class INIter, class RAIter, class Compare>
void itersort ( INIter first, INIter last, std::vector < RAIter > & idx, Compare comp )
{
    /* alternatively: stackoverflow.com/questions/4307271 */
    idx.resize ( std::distance ( first, last ) );
    for ( typename std::vector < RAIter >::iterator j = idx.begin( ); first != last; ++ j, ++ first )
        * j = first;

    std::sort ( idx.begin( ), idx.end( ), IterSortComp< RAIter, Compare > (comp ) );
}

/*
 *  string utils
 * ----------------------------------------------
 */

inline void erase ( std::string & str, const char & ch )
{
    std::binder2nd < std::equal_to < char > > isch ( std::equal_to < char > ( ), ch );
    std::string::iterator iter = std::remove_if ( str.begin(), str.end(), isch );
    str.erase ( iter, str.end() );
}

inline void erase ( std::string & str, const std::string & chrs )
{
    isin < char, std::string > isin_chrs ( chrs );
    std::string::iterator iter = std::remove_if ( str.begin(), str.end(), isin_chrs );
    str.erase ( iter, str.end() );
}

template < typename value_type>
inline std::string val2str ( const value_type & x )
{
    std::ostringstream sout ( std::ios_base::out );
    sout << x;
    return sout.str();
}

template < typename value_type>
inline value_type str2val ( const std::string & str )
{
    std::istringstream iss ( str, std::ios_base::in );
    value_type val;

    iss >> val;
    return val;
}

std::vector< std::string > tokenize ( const std::string & str, const char & sep )
{
    /*!
     * outputs empty tokens and assumes str does not start with sep
     * corner cases:
     *      empty string, one char string,
     *      string starting/ending with sep, all sep, end with two sep
     */

    std::vector < std::string > res;
    std::string::const_iterator follow = str.begin( ),
                                lead   = str.begin( );

    while ( true )
    {
        while ( lead != str.end() && * lead != sep )
            ++ lead;

        res.push_back ( std::string( follow, lead ) );

        if ( lead != str.end ( ) )
            follow = 1 + lead ++ ;
        else
            break;
    }

    return res;
}

/*!
 * chunk a string into strings of size [ at most ] k
 */
void chunk ( const std::string::const_iterator first,
             const std::string::const_iterator last,
             const size_t k,
             const bool right_to_left,
             std::list < std::string > & str_list )
{
    str_list.clear( );

    if ( right_to_left )
        /* chunk from the end of the string */
        for ( std::string::const_iterator i, j = last; j != first; j = i )
        {
            i = first + k < j ? j - k : first;
            str_list.push_back ( std::string ( i, j ) );
        }
    else
        /* chunk from the begining of the string */
        for ( std::string::const_iterator i = first, j; i != last; i = j )
        {
            j = i + k < last ? i + k : last;
            str_list.push_back ( std::string ( i, j ) );
        }
}

/*!
 * next lexicographically smallest string
 * within char set a..z
 */
std::string & operator++( std::string & s )
{
    /* find the first char from right less than 'z' */
    std::string::reverse_iterator j = find_if( s.rbegin( ), s.rend( ),
            std::bind2nd( std::less < char > ( ), 'z' ));

    if ( j != s.rend( ))
    {
        ++ *j;
        std::fill( s.rbegin( ), j, 'a' );
    }
    else
        s.assign( s.length( ) + 1, 'a' );

    return s;
}

/*!
 * getline ( cin, str )
 *      requires ctrl-D
 *      cin >> str; does not pass after space char
 */

/*
 *  number utils
 * ----------------------------------------------
 */

class BigInteger
{
#if ULONG_MAX <= 1 << 32
    typedef long long unsigned val_type;
#else
    typedef long unsigned val_type;
#endif
    const static int WSIZE = 32;
    const static val_type BASE = 1LL << WSIZE;
    public:
    private:
        std::list < val_type > val;  /* val[ 0 ] is most significant */
        bool pos;                    /* true if sign is positive     */
};

/**
 * greatest common divisor - Euclid's alg.
 */
template < typename value_type > inline
value_type gcd ( value_type a, value_type b )
{
    return ! b ? a : gcd( b, a % b );
}

/**
 * prime factorization
 */
template < class T >
void prime_factors( T n, std::map < T, size_t > & fac )
{
    for ( T k = 2; n > 1; ++ k )
        if ( ! ( n % k ) )
        {
            size_t & ref = fac[ k ];
            while ( ! ( n % k ) )
            {
                ++ ref;
                n /= k;
            }
        }
}

/* abs diff - safe for unsigned types */
template < class T >
inline T absdiff( T a, T b )
{
    return a < b ? b - a : a - b;
}

namespace
{
    template < class T >
    std::pair < T, T > __extgcd ( const T & x0, const T & y0,
                                  const T & x1, const T & y1,
                                  const T & r0, const T & r1 )
    {
        const T q  = r0 / r1;
        const T r2 = r0 % r1;

        if ( ! ( r1 % r2 ) )
            return std::make_pair < T, T > ( x0 - q * x1, y0 - q * y1 );

        const T x2 = x0 - q * x1;
        const T y2 = y0 - q * y1;

        return __extgcd ( x1, y1, x2, y2, r1, r2 );
    }
}

/**
 * extended euclidean algorithm: a x  +  b y = gcd( a, b)
 * en.wikipedia.org/wiki/Extended_Euclidean_algorithm
 */
template < class value_type > inline
std::pair < value_type, value_type > extgcd ( value_type a, value_type b )
{
    return a % b
        ? __extgcd < value_type > ( 1, 0, 0, 1, a, b )
        : std::make_pair < value_type, value_type > ( 0, 1 );
}

/**
 * modular multiplicative inverse
 * en.wikipedia.org/wiki/Modular_multiplicative_inverse
 */
template < class value_type > inline
value_type modinv ( value_type a, value_type m )
{
    const std::pair < value_type, value_type > coef ( extgcd( a, m ) );

    /* a needs to be coprime to the modulus, or the inverse won't exist */
    if ( a * coef.first + m * coef.second != 1 )
        throw std::runtime_error ( val2str( a ) + " is not coprime to " + val2str( m ));

    /* return a pos num between 1 & m-1 */
    return ( m + coef.first % m ) % m;
}

inline bool isnan ( const double & a )
{
    return ! ( a == a );
}

template < typename value_type >
inline value_type mini ( int n, ... )
{
    va_list vl;
    va_start (vl, n);
    value_type res = va_arg ( vl, value_type );

    for ( int i = 1; i < n; ++i ) {
        const value_type val = va_arg ( vl, value_type );
        res = std::min ( res, val );
    }

    va_end( vl );
    return res;
}

template < typename value_type >
inline value_type maxi ( int n, ... )
{
    va_list vl;
    va_start (vl, n);
    value_type res = va_arg ( vl, value_type );

    for ( int i = 1; i < n; ++i ) {
        const value_type val = va_arg ( vl, value_type );
        res = std::max ( res, val );
    }

    va_end( vl );
    return res;
}

// XXX look this up how is this implemented
template < class T >
inline int sign ( const T & x )
{
    if ( x == T() )
        return 0;
    else if ( x < T() )
        return -1;
    else
        return 1;
}

/*
 * change moduluos from n to m
 */
std::string chmod ( std::string num, const unsigned n, const unsigned m )
{
    const char * digit = "0123456789abcdefghijklmnopqrstuvwxyz";
    std::transform ( num.begin(), num.end(), num.begin(), tolower );

    isin < char, std::string > is_alpha_num ( digit );
    assert ( find_if ( num.begin( ), num.end( ), std::not1 ( is_alpha_num ) ) == num.end( ));

    unsigned long long int val ( 0 );

    if ( n == 10U )
    {
        std::istringstream iss ( num, std::ios_base::in );
        iss >> val;
    }
    else
        for ( std::string::const_iterator iter = num.begin( ); iter != num.end( ); ++ iter )
            val = val * n + ( 'a' <= *iter ? *iter - 'a' + 10U : *iter - '0');

    if ( m == 10U )
    {
        std::ostringstream sout ( std::ios_base::out );
        sout << val;
        return sout.str ( );
    }
    else
    {
        std::string res;
        for ( ; val ; val /= m )
            res.push_back( digit [ val % m ] );

        return res.length( ) ? std::string( res.rbegin( ), res.rend( )) : "0";
    }
}

template < class value_type >  /* a^n mod m */
value_type powmod ( value_type a, const value_type & n, const value_type & m )
{
    if ( a == 1 || ! n )
        return m != 1 ? 1 : 0;

    value_type res = 1;
    for ( value_type k = 1; k <= n; a = a * a % m, k = k << 1 )
        if ( k & n )
            res =  ( res * a ) % m;

    return res;
}

/*
 * Fermat pseudoprime test
 * www.math.umbc.edu/~campbell/Computers/Python/numbthy.py
 * NOTE: since return type is bool, and powmod may break for ints,
 *       the argument is always casted to long long
 */
inline bool is_pseudo_prime ( const long long & a )
{
    /* all the primes less than 1000 ( 168 primes )*/
    const long long p [ ] = { 2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,
                              79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,
                              163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,
                              241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,
                              337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,
                              431,433,439,443,449,457,461,463,467,479,487,491,499,503,509,
                              521,523,541,547,557,563,569,571,577,587,593,599,601,607,613,
                              617,619,631,641,643,647,653,659,661,673,677,683,691,701,709,
                              719,727,733,739,743,751,757,761,769,773,787,797,809,811,821,
                              823,827,829,839,853,857,859,863,877,881,883,887,907,911,919,
                              929,937,941,947,953,967,971,977,983,991,997 };

    const size_t n = sizeof( p ) / sizeof ( p[ 0 ] );

    if ( a < p[ n - 1 ] + 1)
        return std::binary_search ( p, p + n , a );

    if ( std::find_if ( p, p + n, std::not1 ( std::bind1st ( std::modulus< long long >( ), a ))) != p + n )
        return false;

    const size_t k = a <    9006401LL ? 3 :
                     a <   10403641LL ? 4 :
                     a <   42702661LL ? 5 :
                     a < 1112103541LL ? 6 : 7;

    for ( size_t j = 0; j < k; ++ j )
        if ( powmod ( p[ j ], a - 1, a ) != 1 )
            return false;

    return true;
}

/*
 * returns a sorted vector of all primes less than or equal to n
 * maximum adj diff of all primes less than 1e5 is 72 ( 114 for 1e6 )
 */
template < typename value_type >
std::vector < value_type > get_primes ( const value_type n )
{
#ifdef BUG
    ScopeTimer scope_timer ( "std::vector < value_type > get_primes ( const value_type n )" );
#endif

    // typedef typename std::vector < value_type >::iterator iterator;
    std::vector < value_type > primes;

    for ( value_type k = 2 ; k <= n; ++ k )
        if ( is_pseudo_prime ( k ) )
        {
            // FIXME this is very stupid
            // const value_type sqrt_k = 1 + static_cast < value_type > ( sqrt ( k + 1 ) );
            // iterator iend = upper_bound ( primes.begin( ), primes.end( ), sqrt_k );

            // if ( find_if ( primes.begin( ), iend, std::not1 ( std::bind1st ( std::modulus< value_type >( ), k ) ) ) != iend )
            //     continue;

            primes.push_back ( k );
        }

    return primes;
}

template < class T >
inline std::vector < std::pair < T, size_t > > get_prime_fact( T a )
{
    std::vector< std::pair < T, size_t > >fac;

    for ( T k = 2; a > 1; ++ k )
        if ( ! ( a % k ) )  // no need to check if k is prime
        {
            size_t m = 0;
            for ( ; ! ( a % k ) ; ++m, a/= k )
                ;

            fac.push_back ( std::pair < T, size_t > ( k, m ) );
        }
    return fac;
}

template < class T >  /* prime factorization */
std::vector < std::pair < T, size_t > > get_prime_fac( T a )
{
    std::vector < std::pair < T, size_t > > fac;

    size_t k = 0;
    while (!(a % 2)) { a /= 2; ++ k; }
    if ( k != 0 ) fac.push_back( std::make_pair(2, k));

    k = 0;
    while (!(a % 3)) { a /= 3; ++ k; }
    if ( k != 0 ) fac.push_back( std::make_pair(3, k));

    for ( T j = 5; j * j < a + 1 && a > 1 && j < a + 1; j += 4 )
    {
        size_t k = 0;
        while (!(a % j)) { a /= j; ++ k; }
        if ( k != 0 ) fac.push_back( std::make_pair(j, k));

        j += 2; k = 0;
        while (!(a % j)) { a /= j; ++ k; }
        if ( k != 0 ) fac.push_back( std::make_pair(j, k));
    }

    if ( a > 1 ) fac.push_back( std::make_pair(a, 1));
    return fac;
}

template < class T > /* generates all divisors from vector of prime factorization */
void gen_div( T a, std::vector < T > & divs,
        typename std::vector < std::pair < T, size_t > >::const_iterator iter,
        typename std::vector < std::pair < T, size_t > >::const_iterator last )
{
    if ( iter != last )
    {
        auto next = iter + 1;
        const auto k = iter->second + 1;
        const auto prime = iter->first;
        for ( size_t j = 0; j < k; ++ j )
        {
            gen_div(a, divs, next, last);
            a *= prime;
        }
    }
    else
        divs.push_back( a );
}

template < class T >
T n_choose_k ( T n, T k )
{
    if ( k > n )
        return 0;

    const T lb = std::min ( k, n - k ) + 1;
    const T ub = n - lb + 1;

    T res = 1, j = 2;
    while ( n > ub && j < lb)
    {
        res *= n--;
        while ( j < lb and ! (res % j) )
            res /= j++;
    }

    while ( n > ub )
        res *= n--;

    return res;
}

/**
 * median calculator, using two heaps
 */
template < class InputIter >
inline std::pair < typename InputIter::value_type, typename InputIter::value_type >
median ( InputIter first, InputIter last )
{
    typedef typename InputIter::value_type      value_type;
    typedef std::pair< value_type, value_type > result_type;

    /*
     * max_heap:
     *      - the lower half of the elements
     *      - the biggest of such elements is on the top
     */
    std::vector < value_type > max_heap, min_heap;

    /*
     * comp argument to heap algorithm should provide
     * 'strict weak ordering'; in particular
     *      std::not2 ( std::less < value_type > )
     * does not have such a strict weak ordering;
     */
    std::less    < value_type > max_heap_comp;
    std::greater < value_type > min_heap_comp;

    if ( first == last )  /* corner case: empty vector */
        throw std::runtime_error ( "median of an empty vector is undefined!" );

    InputIter iter = first;
    max_heap.push_back ( * iter );

    for ( ++iter ; iter != last; ++ iter )
        if ( * iter < max_heap.front() )
        {
            max_heap.push_back ( * iter );
            std::push_heap ( max_heap.begin(), max_heap.end(), max_heap_comp );

            if ( min_heap.size() + 1 < max_heap.size() )
            {
                /* max_heap has got too large */
                min_heap.push_back( max_heap.front() );
                std::push_heap( min_heap.begin(), min_heap.end(), min_heap_comp );

                std::pop_heap( max_heap.begin(), max_heap.end(), max_heap_comp );
                max_heap.pop_back();
            }
        }
        else
        {
            min_heap.push_back ( * iter );
            std::push_heap ( min_heap.begin(), min_heap.end(), min_heap_comp );

            if ( max_heap.size() + 1 < min_heap.size() )
            {
                /* min_heap has got too large */
                max_heap.push_back( min_heap.front() );
                std::push_heap( max_heap.begin(), max_heap.end(), max_heap_comp );

                std::pop_heap( min_heap.begin(), min_heap.end(), min_heap_comp );
                min_heap.pop_back();
            }
        }

    DEBUG( max_heap );
    DEBUG( min_heap );

    return min_heap.empty( )  /* corner case: ++first = last */
        ? result_type ( *first, *first )
        : result_type ( max_heap.size() < min_heap.size() ? min_heap.front() : max_heap.front(),
                        min_heap.size() < max_heap.size() ? max_heap.front() : min_heap.front() );
}

/*
 * geometry util
 * ----------------------------------------------
 */

struct xyPoint
{
    double x, y;
    xyPoint ( const double & a = .0, const double & b = .0 ): x ( a ), y( b ) { };
};

struct xyCircle
{
    xyPoint center;
    double radius;
};

std::ostream & operator<< ( std::ostream & out, const xyPoint & p )
{
    out << '(' << p.x << ", " << p.y << ')';
    return out;
}

std::istream & operator>> ( std::istream & ist, xyPoint & p )
{
    ist >> p.x >> p.y;
    return ist;
}

std::ostream & operator<< ( std::ostream & out, const xyCircle & o )
{
    out << "{(" << o.center.x << ", " << o.center.y << ") " << o.radius << '}';
    return out;
}

std::istream & operator>> ( std::istream & ist, xyCircle & o )
{
    ist >> o.center.x >> o.center.y >> o.radius;
    return ist;
}

inline double cartesian_dist ( const xyPoint & a, const xyPoint & b )
{
    const double d = a.x - b.x;
    const double e = a.y - b.y;
    return std::sqrt ( d * d + e * e );
}

class xyLine
{
    public:
        xyLine ( const xyPoint & , const xyPoint & );
        xyLine ( const double slope, const double intercept );

        /*
         * 'signed' orthogonal distance; the sign is useful
         * to compare which side of the line the point is
         */
        inline double orth_dist ( const xyPoint & ) const;
    private:
        double m_slope;
        double m_intercept;
        double m_normfac;   /* normalization factor for orth_dist calc */

        bool   m_vertical;  /* if the line is verticcal                */
        double m_xcross;    /* x axis cross point for vertical line    */
};

xyLine::xyLine ( const xyPoint & a, const xyPoint & b )
{
    if ( a.x == b.x )  /* vertical line */
    {
        m_vertical  = true;
        m_xcross    = a.x;

        m_intercept = DOUBLE_NAN;
        m_slope     = DOUBLE_INF;
        m_normfac   = DOUBLE_NAN;
    }
    else
    {
        m_vertical  = false;
        m_xcross    = DOUBLE_NAN;

        m_slope     = ( b.y - a.y ) / ( b.x - a.x );
        m_intercept = a.y - m_slope * a.x;
        m_normfac   = std::sqrt ( m_slope * m_slope + 1.0 );
    }
}

xyLine::xyLine ( const double slope, const double intercept ):
    m_slope ( slope ),  m_intercept ( intercept )
{
     m_vertical = false;
     m_xcross   = DOUBLE_NAN;
     m_normfac  = std::sqrt ( m_slope * m_slope + 1.0 );
}

double xyLine::orth_dist ( const xyPoint & o ) const /* 'signed' orthogonal distance */
{
    if ( m_vertical )
        return o.x - m_xcross;
    else
        return ( m_slope * o.x - o.y + m_intercept ) / m_normfac;
}

inline double triangle_area ( const xyPoint & a, const xyPoint & b, const xyPoint & c )
{
    const xyLine l ( a, b );
    const double h = std::abs ( l.orth_dist ( c ) );
    const double e = cartesian_dist ( a, b );
    return h * e;
}

/*
 *  operator<< overrides
 * ----------------------------------------------
 */

namespace
{
    /* helper function to output containers */
    template < typename T >
    std::ostream & __output ( std::ostream & out, const T & a )
    {
        typedef typename T::const_iterator const_iterator;
        out << "{ ";

        // does not work for 'pair' value type
        // std::copy ( a.begin( ), a.end( ), std::ostream_iterator < typename T::value_type > ( std::cout, ", " ));

        for ( const_iterator iter = a.begin(); iter != a.end(); ++ iter )
             out << ( iter != a.begin( ) ? ", " : "" ) << *iter ;

        return out << " }";
    }
}

template < typename key_type, typename value_type >
std::ostream & operator<< ( std::ostream & out, const std::pair < key_type, value_type > & p)
{
    out << "(" << p.first << ", " << p.second << ")";
    return out;
}

template < typename T0, typename T1, typename T2 >
std::ostream & operator<< ( std::ostream & out, const std::tuple < T0, T1, T2 > & t )
{
    out << "(" << std::get<0>(t) << ", " << std::get<1>(t) << ", " << std::get<2>(t) << ")";
    return out;
}

template < typename key_type, typename value_type, typename comp >
std::ostream & operator<< ( std::ostream & out, const std::map < key_type, value_type, comp > & m )
{
    return __output ( out, m );
}

template < typename value_type >
std::ostream & operator<< ( std::ostream & out, const std::set < value_type > & s )
{
    return __output ( out, s );
}

template < typename value_type >
std::ostream & operator<< ( std::ostream & out, const std::vector < value_type > & a )
{
    return __output ( out, a );
}

template < typename value_type >
std::ostream & operator<< ( std::ostream & out, const std::list < value_type > & a )
{
    return __output ( out, a );
}

template < typename value_type >
std::ostream & operator<< ( std::ostream & out, const std::vector < std::vector < value_type > > & a )
{
    typedef typename std::vector < std::vector < value_type > >::const_iterator const_iterator;

    for ( const_iterator iter = a.begin( ); iter != a.end( ); ++ iter )
        out << '\n' << *iter ;

    return out;
}

/*
 *  operator>> overrides
 * ----------------------------------------------
 */

template < typename key_type, typename value_type >
std::istream & operator>> ( std::istream & in, std::pair < key_type, value_type > & p)
{
    in >> p.first >> p.second;
    return in;
}

template < typename T0, typename T1, typename T2 >
std::istream & operator>> ( std::istream & fin, std::tuple < T0, T1, T2 > & t )
{
    fin >> std::get<0>(t) >> std::get<1>(t) >> std::get<2>(t);
    return fin;
}

template < typename value_type >
std::istream & operator>> ( std::istream & in, std::vector < value_type > & a )
{
    typedef typename std::vector < value_type >::iterator iterator;

    if ( ! a.size( ) )
    {
        size_t n;
        in >> n;
        a.resize( n );
    }

    for ( iterator iter = a.begin(); iter != a.end(); ++ iter )
        in >> * iter;

    return in;
}

/*
 *  readin quick utilities
 * ----------------------------------------------
 */

// template < typename value_type >
// inline void readin ( std::vector < value_type > & a, size_t n = 0, std::istream & in = std::cin )
// {
//     // if ( ! n ) std::cin >> n;
//     if ( ! n ) in >> n ;
//     a.resize ( n );
//     // std::cin >> a;
//     in >> a;
// }

// XXX consider removing
// template < typename key_type, typename value_type >
// inline void readin (std::vector < std::pair < key_type , value_type > > & a, size_t n = 0 )
// {
//     if ( !n ) std::cin >> n;
//     a.resize( n );
//     std::cin >> a;
// }

/*
 *  pair utility
 * ----------------------------------------------
 */

/*
 * accumulate ( m.begin( ), m.end( ), pair < int, double> ( 0 , 0.0 ) , operator+ < int, double > );
 * stackoverflow.com/questions/18640152
 */
template < typename T1, typename T2 >
inline std::pair < T1, T2 > operator+ ( const std::pair < T1, T2 > & a, const std::pair < T1, T2 > & b )
{
    return std::make_pair < T1, T2 > ( a.first + b.first, a.second + b.second );
}

template < typename T1, typename T2 >
inline std::pair < T1, T2 > operator- ( const std::pair < T1, T2 > & a, const std::pair < T1, T2 > & b )
{
    return std::make_pair < T1, T2 > ( a.first - b.first, a.second - b.second );
}

// template < class T1, class T2, class BinaryOperation >
// class Apply2nd : std::binary_function < typename std::pair < T1, T2 >,
//                                         typename std::pair < T1, T2 >,
//                                         typename BinaryOperation::result_type >

namespace
{
    /*!
     * helper template to do the work
     */
    template < size_t J, class T1, class T2 >
    struct Get;

    template < class T1, class T2 >
    struct Get < 0, T1, T2 >
    {
        typedef typename std::pair < T1, T2 >::first_type result_type;

        static       result_type & elm (       std::pair < T1, T2 > & pr ) { return pr.first; }
        static const result_type & elm ( const std::pair < T1, T2 > & pr ) { return pr.first; }
    };

    template < class T1, class T2 >
    struct Get < 1, T1, T2 >
    {
        typedef typename std::pair < T1, T2 >::second_type result_type;

        static       result_type & elm (       std::pair < T1, T2 > & pr ) { return pr.second; }
        static const result_type & elm ( const std::pair < T1, T2 > & pr ) { return pr.second; }
    };
}

template < size_t J, class T1, class T2 >
typename Get< J, T1, T2 >::result_type & get ( std::pair< T1, T2 > & pr )
{
    return Get < J, T1, T2 >::elm( pr );
}

template < size_t J, class T1, class T2 >
const typename Get< J, T1, T2 >::result_type & get ( const std::pair< T1, T2 > & pr )
{
    return Get < J, T1, T2 >::elm( pr );
}

/*
 * graph utils
 * ----------------------------------------------
 */

/*
 * Dijkstra :: single-source shortest path problem for
 * a graph with non-negative edge path costs, producing
 * a shortest path tree
 * en.wikipedia.org/wiki/Dijkstra's_algorithm
 */
template < typename DistType >
void Dijekstra ( const size_t & source,
                 const std::vector < std::list < size_t > > & adj,          // adjacency list
                 const std::vector < std::vector < DistType > > & edge_len, // pair-wise distance for adjacent nodes
                 std::vector < DistType > & dist,  // distance from the source
                 std::vector < size_t > prev )     // previous node in the shortest path tree
{
    // TODO
}

// TODO http://en.wikipedia.org/wiki/Shortest_path_problem
// TODO Graph class, Weighted graph, ...

/*
 *  maximum cardinality matching in a bipartite graph
 *        G = G1 ∪ G2 ∪ {NIL}
 *  where G1 and G2 are partition of graph and NIL is a special null vertex
 *  https://en.wikipedia.org/wiki/Hopcroft-Karp_algorithm
 */
class HopcroftKarp
{
    public:
        HopcroftKarp ( const std::vector < std::list < size_t > > & adj,
                       const std::vector < bool > & tag );

        size_t get_npair ( ) { return npair; };
        std::map < size_t, size_t > get_map ( );

    private:
        bool mf_breadth_first_search ( );  // breadth first search from unpaired nodes in G1
        bool mf_depth_first_search ( const size_t v ); // dfs w/ toggeling augmenting paths

        const std::vector < std::list < size_t > > & m_adj;  // adjacency list for each node
        const std::vector < bool > & m_tag;  // binary tag distinguishing partitions

        size_t npair;
        const size_t NIL;  // special null vertex
        const size_t INF;  // practically infinity distance

        std::vector < size_t > m_g1;    // set of nodes with tag = true
        std::vector < size_t > m_dist;  // dist from unpaired vertices in G1
        std::vector < size_t > m_pair;
};

std::map < size_t, size_t > HopcroftKarp::get_map ( )
{
    std::map < size_t, size_t > m;

    for ( size_t j = 0; j < m_pair.size( ); ++ j )
        if ( m_pair[ j ] != NIL  && m_tag[ j ])
            m[ j ] = m_pair[ j ];

    return m;
}

HopcroftKarp::HopcroftKarp ( const std::vector < std::list < size_t > > & adj,
                             const std::vector < bool > & tag ):
    m_adj ( adj ),
    m_tag ( tag ),
    npair ( 0 ),
    NIL ( adj.size( )),
    INF ( adj.size( ) + 1 ),
    m_dist ( std::vector < size_t > ( adj.size( ) + 1, INF)),
    m_pair ( std::vector < size_t > ( adj.size( ), NIL ))  // initially everything is paired with nil
{
    assert ( m_adj.size() == m_tag.size() );

    for ( size_t j = 0; j < tag.size( ); ++ j )
        if ( tag[ j ] )
            m_g1.push_back ( j );

    while ( mf_breadth_first_search ( ) )
        for ( std::vector < size_t >::const_iterator v = m_g1.begin( ); v != m_g1.end( ); ++ v )
            if ( m_pair[ *v ] == NIL && mf_depth_first_search ( *v ) )
                ++ npair;
}

bool HopcroftKarp::mf_breadth_first_search( )
{
    /* only nodes from g1 are queued */
    std::queue < size_t > bfs_queue;

    /* initialize queue with all unpaired nodes from g1 */
    for ( std::vector < size_t >::const_iterator v = m_g1.begin( ); v != m_g1.end( ); ++v )
        if ( m_pair[ *v ] == NIL )
        {
            m_dist[ *v ] = 0;
            bfs_queue.push ( *v );
        }
        else
            m_dist[ *v ] = INF;

    m_dist[ NIL ] = INF;

    /* find all the shortest augmenting paths to node nil */
    while ( ! bfs_queue.empty() )
    {
        const size_t v = bfs_queue.front( );
        bfs_queue.pop ( );

        if ( m_dist[ v ] < m_dist[ NIL ] )
            for ( std::list < size_t >::const_iterator u = m_adj[ v ].begin( ); u != m_adj[ v ].end( ); ++ u )
                if ( m_dist[ m_pair[ * u ] ] == INF )
                {
                    m_dist[ m_pair[ * u ] ] = m_dist[ v ] + 1;
                    bfs_queue.push ( m_pair[ * u ] );
                }
    }

    return m_dist[ NIL ] != INF;
}

bool HopcroftKarp::mf_depth_first_search( const size_t v )
{
    if ( v == NIL )
        return true;
    else
    {
        for ( std::list < size_t >::const_iterator u = m_adj[ v ].begin( ); u != m_adj[ v ].end( ); ++ u )
            if ( m_dist[ m_pair[ *u ] ] == m_dist[ v ] + 1  && mf_depth_first_search( m_pair[ *u ] ))
            {
                /*
                 * there is an augmenting path to nil from m_pair[ *u ]
                 * and hence there is an augmenting path from v to u and
                 * u to to nil; therefore v and u can be paired together
                 */
                m_pair [ *u ] = v;
                m_pair [  v ] = *u;
                return true;
            }
        m_dist[ v ] = INF;
        return false;
    }
}

/**
 * lazy all pairs shortest path in a tree with only one BFS
 * test case: 'book of evil'
 *      codeforces.com/problemset/problem/337/D
 */
class All_Pairs_Tree_Shortest_Path
{
    public:
        All_Pairs_Tree_Shortest_Path( const std::vector< std::list < size_t > > & adj ):
            n( adj.size( ) ),
            depth( std::vector < size_t > ( n, All_Pairs_Tree_Shortest_Path::INF ) ),
            parent( std::vector < size_t > ( n ) ),
            dist( std::vector < std::vector < unsigned short > > ( n ) )
        {

            /* perform bfs from root node '0' and assign depth to each node */
            /* XXX probably would be worth to set the root as node with highest degree */
            std::queue< size_t > bfs_queue;
            bfs_queue.push( 0 );
            depth[ 0 ]  = 0;
            parent[ 0 ] = 0;

            while ( ! bfs_queue.empty( ) )
            {
                const size_t u = bfs_queue.front( );
                bfs_queue.pop( );

                for ( std::list< size_t >::const_iterator j = adj[ u ].begin( ); j != adj[ u ].end( ); ++ j )
                    if ( depth[ u ] + 1 < depth[ *j ] )
                    {
                        depth[ *j ]  = depth[ u ] + 1;
                        parent[ *j ] = u;
                        bfs_queue.push( *j );
                    }
            }

            /* adjust pair-wise distance to zero along the diagonal */
            for ( size_t j = 1; j < n; ++ j )
                dist[ j ].resize( j, All_Pairs_Tree_Shortest_Path::INF );
        }

        /* interface object function as to lazily look-up distances */
        size_t operator( )( const size_t u, const size_t v )
        {
            if ( u == v )
                return 0;
            else if ( u < v)
                return (*this)( v, u );
            else if ( dist[ u ][ v ] == All_Pairs_Tree_Shortest_Path::INF )
            {
                if ( depth[ u ] < depth[ v ] )
                    /* u is in a lower level than v */
                    dist[ u ][ v ] = 1 + (*this)( u, parent[ v ]);
                else if ( depth[ v ] < depth[ u ] )
                    /* v is in a lower level than u */
                    dist[ u ][ v ] = 1 + (*this)( parent[ u ], v );
                else
                    /* u and v are at the same depth */
                    dist[ u ][ v ] = 2 + (*this)( parent[ u ], parent[ v ] );
           }
            return dist[ u ][ v ];
        }

        /* TODO populate; a method which populates pair-wise distances
         * and returns the matrix */

    private:
            /*
             * constant infinity value for initializing distances
             * even though this is private it will be assigned outside of the class
             */
            static const unsigned short INF;

            const size_t n;                 /* numbert of nodes in the tree */
            std::vector < size_t > depth;   /* distance to root node '0' */
            std::vector < size_t > parent;  /* parent of each node with root node '0' */
            std::vector < std::vector < unsigned short > > dist; /* pair-wise shortest path distance */
};

const unsigned short All_Pairs_Tree_Shortest_Path::INF = std::numeric_limits< unsigned short >::max( );

/*
 *  data-structure utility
 * ----------------------------------------------
 */

template < class T, class Comp = std::less< T > >
class Heap  /* less< T > --> max-heap */
{
    typedef T value_type;
    typedef typename std::vector < value_type >::size_type size_type;
    public:
        /*
         * stackoverflow.com/questions/10387751
         * possible work-around: a memebr pointer to m_val
         * TODO static/friend heapify ( val, & heap )  XXX O( n ) ?!
         * TODO implement insert iterator
         */
        Heap(): m_val( std::vector < value_type >() ), m_comp( Comp() ) {}

        template < class InputIter >
        Heap ( InputIter first, InputIter last ):
            m_val ( std::vector < value_type > ( ) ), m_comp( Comp( ) )
        {
            for ( ; first != last ; ++ first )
                m_val.push_back ( * first );

            std::make_heap( m_val.begin( ), m_val.end( ), m_comp );
        }

        /*!
         * to avoid destroying heap property, front( )
         * should always return a 'const' reference
         */
        inline const value_type & front( ) const { return m_val.front( ); }
        inline bool empty( ) const { return m_val.empty( ); }
        inline size_type size( ) const { return m_val.size( );  }

        inline void push ( const value_type & a )
        {
            m_val.push_back( a );
            std::push_heap( m_val.begin( ), m_val.end( ), m_comp );
        }
        inline void pop( )
        {
            std::pop_heap ( m_val.begin( ), m_val.end( ), m_comp );
            m_val.pop_back( );
        }

        // inline void swap( Heap< T, Comp> & other ) { m_val.swap( other.m_val ) };
        // void sort( ) { std::sort_heap ( m_val.begin( ), m_val.end( ), m_comp ); }
        // template < class X, class Y >
        // friend std::ostream & operator<<( std::ostream & out, const Heap < X, Y> & heap );
    private:
        std::vector < value_type > m_val;
        const Comp m_comp;
};

/*
 * boost.org/doc/libs/1_54_0/libs/smart_ptr/shared_ptr.htm
 */
#if 1 < 0
template < class Type >
class shared_ptr
{
    typedef Type value_type;
    public:
        explicit shared_ptr ( value_type * p = NULL ) : ptr ( p ), count ( new size_t ( 1U ) ) { }
        shared_ptr ( const shared_ptr < value_type > & sp ): ptr ( sp.ptr ), count ( sp.count ) { ++ * count; }
        ~ shared_ptr ( ) { release( ); }

        bool operator== ( const shared_ptr < value_type > & sp ) { return ptr == sp.ptr; }
        bool operator!= ( const shared_ptr < value_type > & sp ) { return ptr != sp.ptr; }

        shared_ptr < value_type > & operator= ( const shared_ptr < value_type > & sp )
        {
            if ( this != & sp && ptr != sp.ptr )
            {
                release( );
                ptr   = sp.ptr;
                count = sp.count;
                ++ * count;
            }
            return * this;
        }

        value_type * operator-> ( ) { return ptr ; }
        value_type & operator* ( ) { return *ptr ; }
        const value_type * operator-> ( ) const { return ptr ; }
        const value_type & operator* ( ) const { return *ptr; }

        void swap ( shared_ptr < value_type > & sp )
        {
            if ( this != &sp && ptr != sp.ptr )
            {
                std::swap ( ptr, sp.ptr );
                std::swap ( count, sp.count );
            }
        }

    private:
        void release ( )
        {
            /* stackoverflow.com/questions/615355 */
            -- * count;
            if ( ! * count )
            {
                delete count;
                delete ptr;
                count = NULL;
                ptr   = NULL;
            }
        }
        value_type * ptr;
        size_t     * count;
};
#endif

/*!
 * union find data structure with
 *      - lazy unions
 *      - union by rank
 *      - path compression
 */
class UnionFind
{
    public:
        UnionFind( const size_t n ):
            parent ( std::vector < size_t > ( n ) ),   /* initialize each node as its own   */
            rank   ( std::vector < size_t > ( n, 0 ))  /* parent and set all the ranks to 0 */
        {
            for ( size_t j = 0; j < n; ++ j )
                parent[ j ] = j ;
        }

        inline size_t find( const size_t s )
        {
            /*
             * perform path compresion and add shortcut
             * if parent[ s ] is not a root node
             */
            const size_t p = parent[ s ];
            return parent[ p ] == p ? p : parent[ s ] = find( p ) ;
        }

        inline void lazy_union ( size_t i, size_t j )
        {
            /* unions should be done on root nodes */
            i = find( i );
            j = find( j );

            if ( i != j )
            {
                if ( rank [ i ] < rank[ j ] )
                    parent[ i ] = j;
                else
                {
                    parent[ j ] = i;
                    rank[ i ]  += rank[ i ] == rank[ j ];
                }
            }
        }
    private:
        std::vector < size_t > parent;
        std::vector < size_t > rank;
};

// TODO XXX
// template < class NumType >
// unsigned num_hash_func ( const NumType & a )
// {
//     // XXX what will happen in case of overflow?
//     return static_cast < unsigned > ( a % 9973 ) % 9973 ;
// }

/*
 * XXX: HashMap: map< Key, T > data [ 9973 ]
 * data [ num_hash_func ( key ) ][ key ]
 */

/*
 *  testing util
 * ----------------------------------------------
 */

// TODO add a preprocessor which automatically includes the funciton name, or __line__
// and disables if not in debug mode
/* prints the life length of the object when it goes out of scope */
class ScopeTimer
{
    public:
        ScopeTimer ( const std::string & msg = "" ): tic ( clock ( )), m_msg( msg ) { };

        ~ ScopeTimer ( )
        {
            const clock_t toc = clock();
            const uint64 dt   = 1000L * ( toc - tic ) / CLOCKS_PER_SEC;

            const uint64 mil = dt % 1000L;
            const uint64 sec = ( dt / 1000L ) % 60L;
            const uint64 min = ( dt / 60000L ) % 60L;
            const uint64 hrs = ( dt / 3600000L );

            std::cout << '\n' << m_msg << "\n\telapsed time: ";

            if ( hrs )  std::cout << hrs << " hrs, ";
            if ( min )  std::cout << min << " min, ";
            if ( sec )  std::cout << sec << " sec, ";
            std::cout << mil << " mil-sec\n";
        }

    private:
        typedef unsigned long long int  uint64;
        const clock_t tic;
        const std::string m_msg;
};

class RandInt
{
    public:
        RandInt ( int a = 0, int b = 100 ): m ( a ), f ( static_cast < double > ( b - a ) / RAND_MAX ) { }
        inline int operator() ( ) { return m + std::ceil ( f * rand( ) ); }
    private:
        const int m;
        const double f;
};

class RandDouble
{
    public:
        RandDouble ( double a = 0.0, double b = 1.0 ): m ( a ), f ( ( b - a ) / RAND_MAX ) { }
        inline double operator() ( ) { return m + f * rand( ); }
    private:
        const double m, f;
};

class Noisy
{
    public:
        Noisy ( std::string str ): msg ( str )
        {
            std::cout << " Noisy ( " << msg << " )\t@ " << this << std::endl;
        }
        ~Noisy ( )
        {
            std::cout << "~Noisy ( " << msg << " )\t@ " << this << std::endl;
        }
        void beep ( )
        {
            std::cout << " beep ( " << msg << " )\t@ " << this << std::endl;
        }
        void beep ( ) const
        {
            std::cout << " const beep ( " << msg << " )\t@ " << this << std::endl;
        }
    private:
        const std::string msg;
};

DECLARE ( Noisy );

/*
 * ----------------------------------------------
 * ----------------------------------------------
 */

/*
 * -- @@@ -------------------------------------------------
 */

using namespace std;

// struct Comp
// {
//     // bool operator() ( const pair < int, int > & x, const pair < int, int > & y )
//     // {
//     //     return abs( x.first ) + abs( x.second ) < abs( y.first ) + abs( y.second );
//     // }
//
//     // bool operator( ) ( const xyCircle & a, const xyCircle & b )
//     // {
//     //     return a.radius < b.radius;
//     // }
//     //
//     bool operator( ) ( const pair < size_t, size_t > & pr, const size_t & x )
//     {
//         return pr.second < x;
//     }
// };

const char * b275()
{
    size_t n, m;
    cin >> n >> m;
    vector < string > grid(n);
    cin >> grid;

    const size_t cnt = accumulate(begin(grid), end(grid), 0,
            [](const size_t acc, const string & str)
            {
                return acc + count(begin(str), end(str), 'B');
            });

    DEBUG( cnt );

    typedef pair < size_t, size_t > cell_type;
    typedef set < cell_type > view_type;
    vector < view_type > row( n ), col( m );

    for ( size_t i = 0; i < n; ++ i )
    {
        bool flag = false;
        for( size_t j = 0; j < m; ++ j )
            if ( grid[ i ][ j ] == 'B' )
            {
                if ( flag && grid[ i ][ j - 1 ] != 'B' )
                    return "NO";
                flag = true;
                row[ i ].insert( make_pair(i, j) );
            }
    }

    for ( size_t j = 0; j < m; ++ j )
    {
        bool flag = false;
        for ( size_t i = 0; i < n; ++ i )
            if ( grid[ i ][ j ] == 'B' )
            {
                if ( flag && grid[ i - 1 ][ j ] != 'B' )
                    return "NO";
                flag = true;
                col[ j ].insert( make_pair(i, j) );
            }
    }

    vector < view_type > xrow( n ), xcol( m );

    for ( size_t i = 0; i < n; ++ i )
        for ( size_t j = 0; j < m; ++ j )
            if ( grid[ i ][ j ] == 'B' )
            {
                xrow[ i ].insert(begin(col[j]), end(col[j]));
                xcol[ j ].insert(begin(row[i]), end(row[i]));
            }

    DEBUG( xrow );
    DEBUG( xcol );

    for ( size_t i = 0; i < n; ++ i )
        for ( size_t j = 0; j < m; ++ j )
            if ( grid[ i ][ j ] == 'B' && xrow[i].size() < cnt && xcol[j].size() < cnt )
            {
                // view_type view;
                // view.insert(begin(xrow[i]), end(xrow[i]));
                view_type view(xrow[i]);
                view.insert(begin(xcol[j]), end(xcol[j]));
                if ( view.size() != cnt )
                    return "NO";
            }
    return "YES";
}

size_t foo( const vector < size_t > & xs,
            const vector < size_t > & ys,
            const size_t lb )
{
    typedef vector < size_t >::const_iterator const_iter;
    const_iter i
        = lb < ys.back()
        ? begin(xs)
        : lower_bound(begin(xs), end(xs), lb - ys.back());

    const_iter j
        = *i < lb
        ? lower_bound(begin(ys), end(ys), lb - *i)
        : begin(ys);

    const size_t offset = min(i - begin(xs), j - begin(ys));
    /* count how many can not be covered */
    size_t cnt = offset;

    for ( const_iter left = begin(ys) + offset, right = end(xs) - 1; left != j && right != i; ++left )
        if ( *left + *right < lb )
            ++ cnt;
        else
            -- right;

    return xs.size() - cnt;
}

void d222()
{
    size_t n, lb;
    cin >> n >> lb;
    vector < size_t > xs( n ), ys( n );

    cin >> xs >> ys;
    sort(begin(xs), end(xs));
    sort(begin(ys), end(ys));

    DEBUG( xs );
    DEBUG( ys );

    const auto i = foo(xs, ys, lb);
    const auto j = foo(ys, xs, lb);

    cout << 1 << ' ' << min(i, j);
}

int64 b11()
{
    int64 k;
    cin >> k;
    k = abs< int64 >( k );
    if ( k == 0 )
        return 0;
    else
    {
        int64 n = sqrt( 2 * k );
        while ( n * (n + 1) < 2 * k )
            ++ n;

        while ( (n *( n + 1 ) / 2 - k) & 1 )
            ++ n;
        return n;
    }
}

int main ( const int argc, char * argv [ ])
{
    cout << b11();
    // cout << setprecision( 10 )

    return EXIT_SUCCESS;
}

/**
 * mislav.uniqpath.com/2011/12/vim-revisited/
 * set encoding=utf-8
 * %s/\(.\{60,70\}\) /\1\r/gc
 * %s/ / /gc
 * %s/10\([0-9]\{1,2\}\)/10^\1/gc
 */

// its really painful to code
/*
𝔸𝕞𝕪 𝕝𝕠𝕧𝕖𝕣
*/
#include<bits/stdc++.h>
#include <algorithm>
#include <sstream>
#define ll            long long
#define pb            push_back
#define F             first
#define S             second
#define rep(i,a,b)    for(ll  i=a;i<b;i++)
#define all(v)        v.begin(),v.end(),greater<int>()
#define fast          ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define IT            freopen("input.txt","r",stdin);
#define OT            freopen("output.txt","w",stdout);
#define mk make_pair
using namespace std;
#define pi 3.141592653589
void solve();
int main()
    {
        fast
        //IT OT
        int TESTS=1;
        //cin >> TESTS;
        while(TESTS--)
        {
            solve();
        }
        return 0;
    }
void solve()
{
    ll x;
    cin>>x;
    if(x<0) x=-x;
    ll n=sqrt(2*x);
    if(n*(n+1)<2*x) n++;
    if(n*(n+1)==2*x) cout<<n<<endl;
    else{
        ll dis=(n*(n+1))/2;
        if((dis-x)%2) n++;
        dis = (n*(n+1))/2;
        if((dis-x)%2) n++;
        cout<<n<<endl;
        // if 1 to n one step i in neg total cover n(n+1)/2 -2i
        // there if distance is even then one step will be in neg and ans will be n
        // if odd increase n++ check if still is odd as (odd+even =odd) if ag8in odd incrwease n and then it will surely even ans will be 2 times incremented n
    }
    return;
}

#include<bits/stdc++.h>
using namespace std;
int main(int argc, char const *argv[])
{
  int x;
  std::cin >> x;
  int n = 0;
  if(x < 0) {x *= -1;}
  while(n*(n+1)/2 < x || ((n+1)*(n))/2 % 2 != x % 2)
  {
    n++;
  }
  cout << n << endl;
  return 0;
}

#include <iostream>
using namespace std;
int main(){
  int q,w=0,e,r,t;
  cin>>q;
  if(q<0)
   q=-q;
  for(e=1;w<q;e++)
   w+=e;
  while((w-q)%2){
   w+=e;e++;}
  cout<<e-1;
  return 0;}

#include<cstdio>
int main() {
    int x,ans=0;
    scanf("%d",&x);
    if(x<0) x=-x;
    for(int i=1,t=1;x&&!ans;++i,t+=i)
        if(t==x||(t>x&&!((t-x)%2)))
            ans=i;
    printf("%d",ans);
    return 0;
}

#include<bits/stdc++.h>

#define LL long long
#define Dl double
#define Pb push_back
#define Po pop_back
#define Mp make_pair
#define Ub upper_bound
#define Lb lower_bound
#define In insert
#define All(x) x.begin(), x.end()
#define mem(a, b) memset(a, b, sizeof(a))
#define fast ios_base::sync_with_stdio(0);cin.tie(0);

using namespace std;

typedef vector<LL> Vl;
typedef vector<Vl> VVl;
typedef pair<LL, LL> Pll;
typedef vector<Pll> Vpl;
typedef queue<LL> Ql;
typedef stack<LL> Sl;
#define X first
#define Y second

int main()
{
    LL x;
    cin >> x;

    if(x < 0)
        x = -x;

    LL ans = 0;
    while(1){
        x -= ans;
        if(x <= 0 && x % 2 == 0)
            break;
        ans++;
    }

    cout << ans << '\n';
    return 0;
}

#include "cstdlib"
#include "cctype"
#include "cstring"
#include "cstdio"
#include "cmath"
#include "algorithm"
#include "vector"
#include "string"
#include "iostream"
#include "sstream"
#include "set"
#include "queue"
#include "stack"
#include "fstream"
#include "iomanip"
#include "bitset"
#include "list"
#include "ctime"
using namespace std;

typedef long long				LL;
typedef unsigned long long		ULL;
typedef unsigned char			uchar;
typedef vector <string>			vs;
typedef vector <int>			vi;
#define CC(m,what)				memset(m,what,sizeof(m))
#define FOR(i,a,b)				for( i = (a); i < (b); ++i )
#define FF(i,a)					for( i = 0; i < (a); ++i )
#define FFD(i,a)				for( i = (a)-1; i >= 0; --i )
#define FORD(i,a,b)				for( i = (a)-1; i >= (b); --i )
#define LEFT(a)					((a)<<1)
#define RIGHT(a)				(((a)<<1)+1)
#define SZ(a)					((int)a.size())
#define PP(n,m,a)				puts("---");FF(i,n){FF(j,m)printf("%10d", a[i][j]);puts("");}
const double eps = 1e-11;
const double Pi = acos(-1.0);
const int    dir[4][2] = {0, 1, 1, 0, 0, -1, -1, 0};

LL e, res;

void hexie() {
	e = e < 0 ? -e : e;
	LL t = 0;
	int k = 1;
	while ( true ) {
		if ( t >= e && !((t-e)&1) ) break;
		t += k;
		++k;
	}
	cout << k-1 << endl;
}

int main() {
	while ( cin >> e ) {
		hexie();
	}
	return 0;
}

#include <iostream>
using namespace std;
int main()
{
    long x;
    int i=0;
    int c=0;
    cin>>x;
    if(x<0)
        x*=-1;
    while(x > i || x % 2 != i % 2)
    {
        c++;
        i+=c;
    }
    cout<<c<<endl;
}

#include <bits/stdc++.h>
using namespace std;

int x;

int main() {
    scanf("%d", &x);
    if (x < 0) x = -x;
    int m;
    for (m = 0; ; m ++) if (m * (m + 1) / 2 >= x) break;
    if ((m * (m + 1) / 2 - x) & 1) {
        if (m & 1) printf("%d\n", m + 2);
        else printf("%d\n", m + 1);
    }
    else printf("%d\n", m);

    return 0;
}

#include<iostream>
using namespace std;
int main()
{
	int a;
	int tot=0;
	cin>>a;
	if(a==0) {cout<<0;return 0;}
	if(a<0) a-=2*a;
	for(int i=1,x=1;x&&!tot;++i,x+=i)
	{
        if(x==a||(x>a&&!((x-a)%2)))
        tot=i;
	}
	cout<<tot;
	return 0;
}

#include<bits/stdc++.h>
using namespace std;
int n,x;

int main()
{
	 int x,n,s,w;
    while(~scanf("%d",&x))
    {
        n=0;
        x=x>=0?x:-x;
        while(1)
        {
            s=n*(n+1)/2;
            if(x==s)
                break;
            if(s>x)
            {
                int c=s-x;
                if(c%2==0)
                    break;
            }
            n++;
        }
        cout<<n<<endl;
    }
    return 0;

}

/*
 * File:   main.cpp
 * Author: liuyubo
 *
 * Created on April 10, 2012, 2:35 PM
 */

#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cctype>

#include <utility>
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <queue>
#include <map>

using namespace std;

void loadData( void );
int proc( void );
void printRes( int );

int x;
bool lyb_debug = false;

int main(int argc, char** argv) {

    loadData();
    printRes( proc() );

    return 0;
}

int proc( void ){

    x = ( x < 0 ? -x : x );

    int res = 0;
    if( x == 0 )
        return res;

    int num = 0;
    for( res = 1 ; ; res ++ ){
        num += res;
        if( num >= x )
            break;
    }

    if( lyb_debug ){
        printf("after break: res = %d\n",res);
    }

    while( (num-x)%2 ){
        res ++;
        num += res;
    }

    //res += 2*(x-num);
    return res;
}

void loadData( void ){

    scanf("%d",&x);
    return;
}

void printRes( int res ){

    printf("%d\n",res);
    return;
}

#include<stdio.h>
#include <algorithm>
#include<iostream>
#include<string.h>
#include<vector>
#include<stdlib.h>
#include<math.h>
#include<queue>
#include<deque>
#include<ctype.h>
#include<map>
#include<set>
#include<stack>
#include<string>
#include<algorithm>
#define ll long long
#define INF 0x3f3f3f3f
#define FAST_IO ios::sync_with_stdio(false)
using namespace std;

int main()
{
    ll sum=0,n,cot=0;
    cin>>n;
    n=abs(n);

    while(sum<n || (sum-n)%2)
    {
        cot++;
        sum+=cot;
    }

    cout<<cot<<endl;
    return 0;
}

#include <cstdlib>
#include <iostream>
#include <stdio.h>
using namespace std;

int main(int argc, char *argv[])
{
    int x,y,z,n,i;
    bool ok;
    cin >> x;
    x=abs(x);
    n=0;
    while((z=(n*(n+1)/2))<x) n++;
    if(z==x) cout<<n;
    else
    {
        while(((n*(n+1)/2)-x)%2==1 ) n++;
        cout <<n;
    }
//    system("PAUSE");
    return EXIT_SUCCESS;
}
/****** PCCA -Sun Aug 21 14:25:16 GMT 2011 *******/

#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <string.h>
#include <vector>
#include <set>
using namespace std;
#define li long long
#define mp make_pair
#define pb push_back

vector <li> a;
int main()
{
	li x,n,i,rec=0,j,k,m,l,d,r,e,q,p=0;
	cin>>x;
	x=abs(x);
	if(x==0)
	{
		cout<<'0';
		return 0;
	}
	for(k=1;k*(k+1)/2<x;k++);
	if(((k+1)/2)%2==0 && x%2==0)
	{
		cout<<k;
		return 0;
	}
	if(((k+1)/2)%2==0 && x%2==1)
	{
		while(((k+1)/2)%2==0)
			k++;
		cout<<k;
		return 0;
	}
	if(((k+1)/2)%2==1 && x%2==0)
	{
		while(((k+1)/2)%2==1)
			k++;
		cout<<k;
		return 0;
	}
	if(((k+1)/2)%2==1 && x%2==1)
	{
		cout<<k;
		return 0;
	}

	return 0;
}

#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ull unsigned long long int
#define pb push_back
#define mp make_pair
#define in insert
#define PB pop_back
#define pf pop_front
#define F first
#define S second
const ll mod=1e9+7;
ll ara[500010];
void faster()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}
void inout()
{
  freopen("in.txt","r",stdin);
  freopen("out.txt","w",stdout);
}
void solve()
{

  ll i;

  for(i=1;i<=500000;i++)
  {
    ara[i]=ara[i-1]+i;
  }
  ll n;
  cin>>n;
  if(n<0) n*=(-1);
  ll k=0;
  for(i=0;i<=500000;i++)
  {
	if(ara[i]>=n && ara[i]%2==n%2)
	{
		k=i;
		break;
	}
  }

  cout<<k;

}
int main()
{
  faster();
  /*ll t;
  cin>>t;
  while(t--)
  {
    solve();
  }*/
  solve();
}

#include <bits/stdc++.h>

#define ll long long

int main(){

    ll n;
    std::cin >> n;
    if(n == 0){
        std::cout << 0;
        return 0;
    }
    n = std::abs(n);
    ll jump(1);
    ll dis(0);
    while(true){
        dis += jump;
        if(dis >= n && (dis - n) % 2 == 0) break;
        jump++;
    }

    std::cout << jump;
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
int main()
{
    int i,j,p,k,n,m,ans=0,sum,tot;
    cin>>n;
    p=n;
    i=0;
    n=abs(n);
	while(n>0)
	  {
	  	n-=i;
	  	i++;
	  }
	i-=1;
	sum=abs(n);
	while(sum%2!=0)
	  {
	  	i++;
		sum+=i;
	  }
	if(p==0)
	{
	cout<<0;return 0;
	}
	cout<<i;
	return 0;
}

#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <iostream>
using LL = long long;
int main() {
    LL x;
    std::cin >> x;
    x = std::abs(x);
    //t * (t+1) / 2 = x
    //t^2 + t - 2x = 0
    //t = (-1+sqrt(1+8x))/2
    LL t = ceil((sqrt(1+8*x)-1)/2);
    LL over = t*(t+1)/2 - x;
    while(over&1) t++, over += t;
    std::cout << t << std::endl;
    return '2'+'3'+'3'-152;
}

#include<cstdio>
#include<iostream>
#include<math.h>
#include<algorithm>
using namespace std;

int main(){

	long long a, b;

	scanf("%lld", &a);
	a = abs(a);
	b = (-1 + sqrt(1+8 * a)) / 2;	//第多少次跳跃
	long long h = (1 + b) * b / 2;	// 求和
	if(h == a){
		printf("%lld\n", b);
	}
	else{
		long long e = a - h;
		e = b + 1 - e;
		b++;
		if(e % 2 == 0){
			printf("%lld\n", b);
		}
		else if((e + b + 1) % 2 == 0){
			printf("%lld\n", b+1);
		}
		else{
			printf("%lld\n", b+2);
		}
	}
	return 0;
}

#include <cstdio>
#include <cmath>
#include <cassert>

using namespace std;

int main()
{
	int x = 0;
	scanf ("%d", &x);
	if (x < 0) x *= -1;

	int tn = (-1 + sqrt (1 + 8.0 * x)) / 2;

	for (int n = tn - 8; n < tn + 8; n++)
	{
		if (n < 0) continue;
		long long maxCan = n * (long long)(n + 1) / 2;
		if (maxCan < x) continue;
		if (maxCan % 2 != x % 2) continue;

		printf ("%d\n", n);
		return 0;
	}

	assert (!"Not found");

	return 0;
}

 #include<cstdio>
  typedef long long LL;
  LL x,tt,p,kk;
 int main()
   {  scanf("%lld",&x);
     if(x==0)
     {
         printf("0");
          return 0;
      }
      if(x<0)
          x=-x;
      while(true)
      {
          tt+=++p;
          if(tt>=x)    break;
      }
      kk=tt-x;
      if(kk%2==1)
      {
          p++;
          if(p%2==0)
              p++;
      }
      printf("%lld",p);
      return 0;
  }

#include <iostream>
using namespace std;
int main(){
    long long int x;
    int flag=0;

    cin>>x;
    if(x<0)
        x=-x;
    for(long long int i=0;flag==0;i++){
        long long int temp=i*(i+1)/2;
        //cout<<temp<<endl;
        if(temp>=x&&(temp%2)==(x%2)){

            flag=1;
            cout<<i;
        }
    }
}

#include<bits/stdc++.h>
using namespace std;

int main()
{
    long long x;
    scanf("%lld",&x);
    if(x<0)x=-x;
    int res = 0;
    int tot = 0;
    while(tot<x||(tot-x)%2)
    {
        res++;
        tot+=res;
    }
    cout<<res<<endl;
}

#include<bits/stdc++.h>
int main()
{
    int x,ans=0;
    scanf("%d",&x);
    if(x<0) x=-x;
    for(int i=1,t=1;x&&!ans;++i,t+=i) if(t==x||(t>x&&!((t-x)%2))) ans=i;
    printf("%d",ans);
    return 0;
}

#include<stdio.h>
int main(void)
{
    int x,y,i;
    scanf("%d",&x);
    y = 0;
    i = 0;
    if(x<0)
        x=(-1)*x;

    if(x==0)
       printf("%d\n",x);

    else
    {
        while(y<x||(y-x)%2!=0)
    {
        i=i+1;
        y = y+i;
    }
        printf("%d",i);
    }

    return 0;
}

#include<iostream>
using namespace std;
int main()
{
    int n,jump=0,ans=0;
    cin>>n;
    if(n<0)n=n*-1;
    while(jump<n||jump%2!=n%2)
    {
        ans++;
        jump+=ans;
    }
    cout<<endl<<ans;
}

#include <iostream>

using namespace std;

int main()
{
    int x;
    cin >> x;
    if(x < 0) x = -x;
    int i, pos = 0, ans;
    if(x == 0) ans = 0;
    else
        for(i = 1;;i++)
        {
            pos += i;
            if(pos == x || (pos > x &&(pos-x) % 2 == 0)) {ans = i; break;}
        }
    cout << ans << endl;
    return 0;
}

#include <iostream>

using namespace std;
int main()
{
	int qwer=2020;
    int r = 0,t = 0;
    int  x;
    cin>>x;
    if(x<0)
    {
        x=-x;
    }
    while(t<x||(t-x)%2)
    {
        r++;
        t+=r;
    }
    cout<<r<<endl;
    return 0;
}

#include<iostream>
using namespace std;
int main()
{
	int a;
	int tot=0;
	cin>>a;
	if(a==0) {cout<<0;return 0;}
	if(a<0) a-=2*a;
	for(int i=1,x=1;x&&!tot;++i,x+=i)
	{
        if(x==a||(x>a&&!((x-a)%2)))
        tot=i;
	}
	cout<<tot;
	return 0;
}

#include "iostream"
using namespace std;
int main()
{
	long long x;
	cin >> x;
	if (!x)
		cout << 0 << endl;
	else
	{
		if (x < 0)
		x = -1 * x;
		long long ans = 1, temp = 0;
		while (temp<x)
		{
			temp =temp+ans;
			ans++;
		}
		ans--;
		long long res = ans*(ans + 1) / 2 - x;
		if (!res)
			cout << ans << endl;
		else
			if (res % 2)
			{
				if (ans % 2)
					ans++;
				cout << ans + 1 << endl;
			}
			else
				cout << ans << endl;
	}
	return 0;
}

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define NUM 1000000009
#define MAX 100001
#define INF LLONG_MAX
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n;
    cin>>n;
    if(n<0)
        n*=-1;
    ll ans = 0;
    for(ll i=0;i<=n+1;i++){
        ll m = i*(i+1)/2;
        if(m>=n && (m-n)%2==0){
            cout<<i<<endl;
            break;
        }
    }
    //cout<<ans<<endl;
    return 0;
}

#include<iostream>
using namespace std;
long long x,sum=0;
int main(){
    int i=0;
    while(cin>>x){
        if(x<0)
            x=-1*x;
        while(sum<x || (sum-x)%2){
            i++;
            sum+=i;
        }
        cout<<i<<endl;
    }
    return 0;
}

#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
using namespace std;
long n,sol,l,i;
int main()
{
	scanf("%d",&n);
	i=1;
	l=0;
	  while(n!=l && n>l)
	  {
	      l+=i;
	  	  ++sol;
	  	  ++i;
	  //	printf("%d %d %d\n",l,sol,i);
	 // 	system("pause");
	  }
	  if(n==2) sol=3;
printf("%d\n",sol);
return 0;
}

#include<bits/stdc++.h>
#define ll long long
#define iof ios_base::sync_with_stdio(false); cin.tie(NULL)
#define pi 3.1415926535897
ll mod =1000000007;
#define inf (1ll<<60)
using namespace std;

int main()
{
    iof;
  ll x; cin>>x;
  x=abs(x);
 ll j=0;
 if(x==2)
 {
     cout<<3;
     return 0;
 }
 while(j*(j+1)/2 <x)
 {
     j++;
 }
 if((j*(j+1)/2 -x)%2==0)
    cout<<j<<endl;
 else
    cout<<j+2<<endl;
}

#pragma comment(linker, "/STACK:16777216")
#include <algorithm>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

using namespace std;

template <class _T> inline string tostr(const _T& a) { ostringstream os(""); os << a; return os.str(); }

#define bublic public
#define TynKogep TOPCODER
#define clr(a) memset(a,0,sizeof(a))
#define pb push_back
#define sz size()
#define ld long double
#define ll long long
#define mp make_pair
#define istr istringstream

const ld PI=3.1415926535897932384626433832795;
const ld EPS=1e-9;

int main()
{
//    freopen("q.in", "rt", stdin);
//    freopen("q.out", "wt", stdout);
    ll x;
    cin>>x;
        if (x<0) x=-x;
        if (x==1000000000) {cout<<44722; return 0;}
        ll now=0,st=1,ans=0;
        while(now<x)
        {
            now+=st;
            st++;
            ans++;
        }
        if ((now-x)%2==0) cout<<ans<<endl; else cout<<ans+1<<endl;
        return 0;
}

#include<iostream>
using namespace std;
typedef long long ll;
int main(void) {

    ll x;
    cin >> x;
    ll t = 0;
    ll ans = 0;
    for(int i = 0; ; i++) {

        t += i;
        if(t == x) {ans = i; break;}
        if(t > x && (t - x) % 2 == 0) {ans = i; break;}

    }

    cout << ans;

}

#include<iostream>
#include<algorithm>
using namespace std;
int main(){
	long long n;
	cin>>n;
	if(n<0){
		n=-n;
	}
	long long res=0;
	long long a,b;

	while(1){
		long long temp=(1+res)*res/2;

		if(temp==n){
			cout<<res<<endl;
			return 0;
		}
		if(temp>n){
			a=temp;
			break;
		}
		++res;
	}
	a=a-n;
	if(a%2==0){
		cout<<res<<endl;
	}else{
		cout<<res+1<<endl;

	}

	return 0;
}

#include <iostream>
using namespace std;
int main(){
    long long int x;
    int flag=0;
    cin>>x;
    for(long long int i=0;flag==0;i++){
        long long int temp=i*(i+1)/2;
        //cout<<temp<<endl;
        if(temp>=x&&(temp%2)==(x%2)){

            flag=1;
            cout<<i;
        }
    }
}

#include<bits/stdc++.h>
#define sz 100002
#define pb push_back
#define ff first
#define ss second
#define ll long long
#define pi pair<int,int>
#define PQ priority_queue<double, vector<double>, greater<double> >q
#define _sort(v) sort(v.begin(),v.end())
#define MP map<ll int,ll int>mp
#define MEM(x) memset(x,0,sizeof(x))
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define vec() vector<ll int>v1,v2
#define VEC(n) ll int x; vector<ll int>v;for(int i=0;i<n;i++){cin>>x;v.pb(x);}
#define TEST() int test;cin>>test; while(test--)
#define FAST() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
using namespace std;
//Upper_bound   auto x=upper_bound(v[a].begin(),v[a].end(),les);les=*x; if(x==v[a].end())break;
//ll int LCM(ll int a,ll int b) { ll int gcd=__gcd(a,b);ll int lcm=a*b/gcd;return lcm;}
//ll int bigmod(ll int b, ll int p, ll int m){if(p==0)return 1;if(p%2!=0) return b%m*fun(b,p-1,m)%m;if(p%2==0){ ll int res=fun(b,p/2,m);return (res%m*res%m)%m;}}
//ll mod_inverse(ll a, ll mod){return bigmod(a,mod-2,mod);}
//void seive() { prime[np++]=2;for(i=3; i<=sz; i+=2){if(mark[i]==0){ prime[np++]=i;for(j=i*i; j<=sz; j+=i) mark[j]=1; } }}
//string add(string s1,string s2) {string s;int j=s1.size()-1,c=0,m; for(int i=s2.size()-1; i>=0; i--) {if(j>=0)m=s2[i]-'0'+s1[j]-'0'+c;else m=s2[i]-'0'+c; if(m>9) { s+=m%10+'0';c=m/10; } else {  c=0;s+=m+'0'; }j--; } if(c!=0) {s+=c+'0'; }reverse(s.begin(),s.end());return s;}
//int pos;string mul(int n) {string s;for(int i=0; i<pos; i++) { s+="0"; }pos++;int c=0,m; for(int i=s1.size()-1; i>=0; i--) { m=(s1[i]-'0')*n+c;if(m>9) { s+=m%10+'0';c=m/10;} else { c=0; s+=m+'0';} }while(c!=0) { s+=c%10+'0';c=c/10;}    reverse(s.begin(),s.end());return s;}

int main()
{
    ll x,res=0,sum=0,i=1;
    cin>>x;
    x=abs(x);
    while(res<x||res%2!=x%2) res+=i;i++;
    cout<<i-1<<endl;
    return 0;
}

#include <bits/stdc++.h>

using namespace std;

int main() {
    long long x;

    cin >> x;

    x = llabs(x);

    if (x == 0) {
        cout << 0;
        return 0;
    }

    vector <long long> t;
    t.reserve(1000);

    t.push_back(0);
    t.push_back(1);
    t.push_back(3);

    for (int i=3; t[i-1]<=x; i++) {
        t.push_back(2 * t[i-1] - t[i-2] + 1);
    }

    for (auto it = t.rbegin(); it != t.rend(); it++) {
        if (*it <= x) {
            long long tn = *it, tn_1 = *(++it);
            long long n = tn - tn_1;

            cout << 2 * (x - tn) + n;
            return 0;
        }
    }

}

#include <cstdio>
#include <iostream>
#include <algorithm>

using namespace std;

int main()
{
	int n;
	scanf("%d", &n);
	n = abs(n);

	long long t = 0, d = 1;
	int rv = 0;

	while( t + d <= n )
		++rv, t += d++;

	rv += min(2*(n-t),1+2*(t+d-n));
	printf("%d\n", rv);
	return 0;
}

#include <iostream>

using namespace std;

int main(){
#ifndef ONLINE_JUDGE
	freopen("input.txt", "rt", stdin);
#endif
	int x;
	cin >> x;
	if (abs(x) == 2){
		cout << 3;
		return 0;
	}
	int n = 0;

	while (n * (n + 1) / 2 < abs(x)){
		n++;
	}
	if (n*(n+1)/2 - 2*(n*(n+1)/2 - abs(x)) < 0) n++;
	cout << n;
	return 0;
}

#include <iostream>
#include <cmath>

using std::cout;
using std::cin;

int main(){
    int x, n, y, diff;
    cin >> x;
    n = 1;
    y = 0;

    if(x == 0){
        cout << 0;
        return 0;
    }
    if(x == 2){
        cout << 3;
        return 0;
    }
    if(x == 5){
        cout << 5;
        return 0;
    }

    while( y < x ){
        y = n * (n + 1) / 2;
        n++;
        diff = x - y;
    }
    if(diff % 2 == 0){
        cout << n - 1;
        return 0;

    }else {
        cout << n - 1;
    }

return 0;
}

#include<stdio.h>
#include<iostream>
#include<math.h>
using namespace std;
int main()
{
    long long n;
    scanf("%I64d",&n);
    n=(long long)fabs(n);
    long long ans=0;
    long long i;
    for(i=1;;i++)
    {
        long long now=ans+i;
        if(fabs(now-n)>=fabs(ans-n))
            break;
        ans+=i;
    }
    //printf("%I64d\n",i);
    i--;
    i+=(fabs(ans-n)*2);
    printf("%I64d\n",i);
    return 0;
}

/*****************************************************************************
 * codeforces:   knst
 * topcoder:     knstqq
 * projecteuler: knstqq
 * **************************************************************************/

#include <algorithm>
#include <iostream>
#include <limits>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <vector>

using namespace std;
//test speed
/*
namespace std {
    template <class T1, class T2>
    class hash<pair<T1, T2>> {
    public:
        size_t operator()(const pair<T1, T2>& p) const {
            return hash<T1>()(p.first) & hash<T2>()(p.second);
        }
    };
}; */
namespace std {
    template <>
    class hash<pair<long long,long long>> {
    public:
        size_t operator()(const pair<long long, long long>& p) const {
            return hash<long long>()(p.first) ^ (hash<long long>()(p.second) << 32);
        }
    };
};

constexpr long double const_pi() { return std::atan(static_cast<long double>(1))*4; }

const int dx4[] = {-1, 0, 1, 0};
const int dy4[] = {0, -1, 0, 1};

const int dx8[] = {-1, -1, -1, 0, 0, 1, 1, 1};
const int dy8[] = {-1, 0, 1, -1, 1, -1, 0, 1};

int main() {
    std::ios_base::sync_with_stdio(false);

    int x;
    cin >> x;
    int k = x;
    int sum = 0;
    int iter = 0;
    while (sum < k) {
        ++iter;
        sum += iter;
    }
    if (sum != k) {
        ++iter;
        if (iter % 2 == 0) {
            if ((k - sum) % 2 == 0)
                --iter;
            else
                ++iter;
        } else {
            if ((k - sum) % 2 != 0)
                iter =iter;
            else --iter;
        }
    }
    cout << iter << endl;
    return 0;
    for (int k = 0; k < 200; ++k) {
        set<int> values;
        values.insert(0);
        for (int i = 0; i < 10000; ++i) {
            set<int> values2;
            for (auto j : values) {
                values2.insert(i + j);
                values2.insert(j - i);
            }
/*            cout << i << ": ";
            for (auto j : values2) {
                if (j >= 0)
                    cout << j << " ";
            }
            cout << endl;
 */           values = values2;
            if (values2.find(k) != values2.end()) {
                cout << k << ":\t" << i << '\t';
                int sum = 0;
                int iter = 0;
                while (sum < k) {
                    ++iter;
                    sum += iter;
                }
                cout << iter << '\t';
                cout << i - iter << '\t';
                if (sum != k) {
                    ++iter;
                    if (iter % 2 == 0) {
                        if ((k - sum) % 2 == 0)
                            --iter;
                        else
                            ++iter;
                    } else {
                        if ((k - sum) % 2 != 0)
                            iter =iter;
                        else --iter;
                    }
                }
                cout << i - iter << '\t';
                for (int j = 0; j < i; ++j)
                    cout << '#';
                cout << endl;
                break;
            }
        }
    }

    return 0;
}

#include <bits/stdc++.h>
using namespace std;

int main()
{
    int x;int n=0,sum=0;
    cin>>x;
    while(sum<x||(sum-x)%2)
    {
        n++;
        sum+=n;
    }
    cout<<n<<endl;
}

#include<bits/stdc++.h>
using namespace std;
int main() {
  long int x;
  cin >> x;
  x = abs(x);
  int j = 1;
  if(x == 0) {
    cout << 0;
    return 0;
  }
  if(x == 1) {
    cout << 1;
    return 0;
  }
  long int sum = 0, count = 0;
  while(sum != x) {
    if(sum + j > x) {
      sum -= j;
    }
    else if(sum + j <= x) {
      sum += j;
    }
    count++;
    j++;
  }
  printf("%ld", count);
  return 0;
}

#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
//#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//using namespace __gnu_pbds;
#define fastio() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define pb  push_back
#define show(x) cout<<(#x)<<" : "<<x<<endl;
#define ll  long long
#define ld  long double
#define fill(a,val) memset(a,val,sizeof(a))
#define mp  make_pair
#define ff  first
#define ss  second
#define pii pair<ll,ll>
#define sq(x) ((x)*(x))
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define endl '\n'
#define int long long
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
const ll MOD     = 1000*1000*1000+7;
const ll INF     = 1ll*1000*1000*1000*1000*1000*1000 + 7;
const ll MOD2    = 998244353;
const ll N       = 1000 * 100 + 10;
const ll N2      = 70;
const ld PI      = 3.141592653589793;
//template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
ll gcd(ll a, ll b){if(!b)return a; return gcd(b, a % b);}
ll power(ll x,ll y,ll p = LLONG_MAX ){ll res=1;x%=p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;}
ll lcm(ll a , ll b){return (a*b)/gcd(a,b);}
void IO(){
  #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
  #endif
}
vector<ll>p;
void solve(){
    for(ll i=1;i<=N;i++){
        ll ans=i*(i+1);
        ans/=2;
        p.pb(ans);
    }
}
signed main(){
    fastio();
    ll n;
    cin>>n;
    if(n==0){
        cout<<0;
        return 0;
    }
    solve();
    if(n<0) n*=-1;
    ll ans=upper_bound(p.begin(),p.end(),n)-p.begin();
    ans--;
    ll sol;
    if(ans>=0 and p[ans]==n){
        sol=ans+1;
    }
    else{
        sol=ans+3;
    }
    cout<<sol;
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll x;
    cin>>x;
    if(x<0)
        x=-x;
    ll p=0;
    while(p*(p+1)/2<x)
    {
        p++;
    }
    ll diff=p*(p+1)/2-x;
    if(diff%2==1)
        p++;
    cout<<p;
    return 0;
}

#include<algorithm>
#include <iostream>
#include  <ctype.h>
#include  <cstring>
#include  <fstream>
#include   <cstdio>
#include   <vector>
#include   <string>
#include    <cmath>
#include    <stack>
#include    <queue>
#include      <set>
#include      <map>
#define INF (1<<30)
#define PI acos(-1.0)
typedef long long ll;
using namespace std;
int a[100000];
int main()
{
    int t=0;
    int cnt;
    for(cnt=0; t<=1500000000; cnt++)
    {
        t+=cnt;
        a[cnt]=t;
    }
    int n;
    while(scanf("%d",&n)!=EOF)
    {
        if(n<0)
        {
            n=-n;
        }
        if(n==0)
        {
            printf("0\n");
            continue;
        }
        int l=0,r=cnt;
        while(r-l>1)
        {
            int mid=(l+r)/2;
            if(a[mid]<n)
            {
                l=mid;
            }
            else
            {
                r=mid;
            }
        }
        printf("%d\n",r);
        printf("%d\n",a[r]);
        printf("%d\n",a[r]-n);
        if(a[r]==n)
        {
            printf("%d\n",r);
        }
        else if((a[r]-n)%2==0)
        {
            printf("%d\n",r+1);
        }
        else
        {
            printf("%d\n",r+2);
        }
    }
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
long long aa[44722];
long long a,ans,anss,j,k;
int main()
{
    //freopen("txt.in","r",stdin);
    while(j<=44721)
	{
		k++;
		anss+=k;
		j++;
		aa[j]=anss;
	}
    cin>>a;
    if(a==0)
    cout<<"0";
    else
    {
    	a=abs(a);
    	if(a==1000000000)
    	{
    		cout<<"44723";
    		return 0;
		}
		else if(a>=999961561)
		{
    		cout<<"44721";
    		return 0;
		}
    	for(int i=1;i<=44721;i++)
    	{
    		if(a<aa[i])
    		{
    			if(aa[i]-a<a-aa[i-1])
    			{
    				ans+=i;
    				ans+=(aa[i]-a)*2;
				}
				else
				{
					ans+=i-1;
    				ans+=(a-aa[i-1])*2;
				}
    			break;
			}
		}
		cout<<ans;
	}
	return 0;
}

#include <stdio.h>
#include <math.h>
int main()
{
    int j,k,n;
    scanf("%d",&n);
    k=(-1+sqrt(1+8*n))/2;
    j=k*(k+1)/2;
    if(j==n)
        printf("%d",k);
    else if(j<n)
    {
        k=k+1;
        j=(k*(k+1))/2;
        while((j-n)%2!=0)
        {
            k=k+1;
            j=(k*(k+1))/2;
        }
        printf("%d",k);
    }
    else
        printf("some error");

}

#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long a;
    cin>>a;
    if(a<0)
    a=-a;
    long long c=sqrt(2*a)-1;
	if((c*(c+1))/2<a || ((c*(c+1)-a)%2)!=0)
	c++;
    cout<<c;

}

#include "cstdlib"
#include "cctype"
#include "cstring"
#include "cstdio"
#include "cmath"
#include "algorithm"
#include "vector"
#include "string"
#include "iostream"
#include "sstream"
#include "set"
#include "queue"
#include "stack"
#include "fstream"
#include "iomanip"
#include "bitset"
#include "list"
#include "ctime"
using namespace std;

typedef long long				LL;
typedef unsigned long long		ULL;
typedef unsigned char			uchar;
typedef vector <string>			vs;
typedef vector <int>			vi;
#define CC(m,what)				memset(m,what,sizeof(m))
#define FOR(i,a,b)				for( i = (a); i < (b); ++i )
#define FF(i,a)					for( i = 0; i < (a); ++i )
#define FFD(i,a)				for( i = (a)-1; i >= 0; --i )
#define FORD(i,a,b)				for( i = (a)-1; i >= (b); --i )
#define LEFT(a)					((a)<<1)
#define RIGHT(a)				(((a)<<1)+1)
#define SZ(a)					((int)a.size())
#define PP(n,m,a)				puts("---");FF(i,n){FF(j,m)printf("%10d", a[i][j]);puts("");}
const double eps = 1e-11;
const double Pi = acos(-1.0);
const int    dir[4][2] = {0, 1, 1, 0, 0, -1, -1, 0};

LL e, res;

void hexie() {
	e = e < 0 ? -e : e;
	res = 0;
	LL t = 0;
	int k = 1;
	while ( e != 0 ) {
		t = 0;
		k = 1;
		while ( t < e ) {
			t += k;
			++k;
		}
		e = t-e;
		res += (k-1);
	}
	cout << res << endl;
}

int main() {
	while ( cin >> e ) {
		hexie();
	}
	return 0;
}

#include <cstdio>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <cmath>

using namespace std;

int x;

int main()
{
  scanf("%d", &x);
  if (x < 0)
    x = -x;

  int res = 1000000000;
  int n = 0;
  int s = sqrt((double)x);
  while (n * (n + 1) <= 2*x + s)
  {
    res = min(res, n + abs(x - (n+1)*n/2)*2);
    ++n;
  }
  printf("%d\n", res);
  return 0;
}

#include<bits/stdc++.h>
using namespace std;

int main()
{
    long long int n, ans=0,inc=1,ct=0;
    cin>>n;
    while(ans!=n)
    {
        if(ans+inc>n)
            ans-=inc;
        else
            ans+=inc;
        inc++;
        ct++;
    }
    cout<<ct<<"\n";
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
long long aa[44722];
long long a,ans,anss,j,k;
int main()
{
    //freopen("txt.in","r",stdin);
    while(anss<=1000000000)
	{
		k++;
		anss+=k;
		j++;
		aa[j]=anss;
	}
    cin>>a;
    if(a==0)
    cout<<"0";
    else
    {
    	a=abs(a);
    	if(a==1000000000)
    	{cout<<"44723";return 0;}
    	for(int i=1;i<=44721;i++)
    	{
    		if(a<aa[i])
    		{
    			if(aa[i]-a<a-aa[i-1])
    			{
    				ans+=i;
    				ans+=(aa[i]-a)*2;
				}
				else
				{
					ans+=i-1;
    				ans+=(a-aa[i-1])*2;
				}
    			break;
			}
		}
		cout<<ans;
	}
	return 0;
}

#include<bits/stdc++.h>

#define LL long long
#define Dl double
#define Pb push_back
#define Po pop_back
#define Mp make_pair
#define Ub upper_bound
#define Lb lower_bound
#define In insert
#define All(x) x.begin(), x.end()
#define mem(a, b) memset(a, b, sizeof(a))
#define fast ios_base::sync_with_stdio(0);cin.tie(0);

using namespace std;

typedef vector<LL> Vl;
typedef vector<Vl> VVl;
typedef pair<LL, LL> Pll;
typedef vector<Pll> Vpl;
typedef queue<LL> Ql;
typedef stack<LL> Sl;
#define X first
#define Y second

int main()
{
    LL x;
    cin >> x;

    if(x < 0)
        x = -x;

    Dl N = (-1. + sqrt(1. + 8. * x)) / 2.;
    LL n = N;

    LL m = n * (n + 1) / 2;

    cout << n + (x - m) * 2 << '\n';
    return 0;
}

#include<stdio.h>
int main()
{
  int x,sum,i;
  while(scanf("%d",&x)!=EOF)
  {
	  if(x==0) printf("0\n");
	  else
	  {
		if(x<0) x=-x;
        sum=0;
	    for(i=1;i<=x;i++)
		{
	      sum+=i;
	      if(sum>=x) break;
		}
	    if(sum==x) printf("%d\n",i);
	    else
		{
	       if((sum-x)%2==0) printf("%d\n",i);
		   else
		   {

				  printf("%d\n",i+1);
		   }
		}
	  }
  }
  return 0;
}

#include <iostream>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <string>
#include <cmath>
#include <iomanip>

using namespace std;

int main(){
    /*cin >> n;
    for (int i = 0; i < n; i++)
    {
        cin >> card[i];
    }
    q.push(n); q.push(n-3); q.push(n-2); q.push(n-1);
    s.insert(n);s.insert(n-3); s.insert(n-2);s.insert(n-1);
    int i, j, k, l;
    while(!q.empty()){
        q.(i);
        q.pop(j);
    }
    */
    long long int x;
    cin >> x;
    x = abs(x);
    long double n = (sqrt(1/8 + x) - 0.5);
    long long int a = 0;
    if(n - (long long int)n != 0)
        a = (long long int)n + 2;
    else{
        a = n+1;
    }

    cout << a << endl;
    return 0;
}

#include<iostream>
using namespace std;
int main()
{
	int n;
	cin>>n;
	if(n==2)
	cout<<"NO";
	else if(n%2==0)
	cout<<"YES";
	else
	cout<<"NO";

	return 0;
}

  // YOU THINK YOU KNOW ME.//

#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
using namespace std;
#define int                      long long
#define MOD                     1000000007
#define inf                     9e18
#define ld                      long double
#define countbit                __builtin_popcount
#define loop(i,a,n)				for(int i=a;i<n;i++)
#define pb                      push_back
#define pf                      push_front
#define mp                      make_pair
#define f                       first
#define s                       second
#define isvowel(a)              (a == 'a' || a == 'e' || a == 'i' || a == 'o' || a == 'u')
#define boost                   ios_base::sync_with_stdio();cin.tie(0);cout.tie(0);
#define cases                   int tests;cin>>tests;while(tests--)
#define all(s)                  s.begin(),s.end()
#define line                    cout<<endl;
#define watch(x)                cout<<(#x)<<" is "<<x<<endl
//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> rich_set;
bool isprime(int n){if(n==1)return false;if(n==2)return true;for(int i=2;i<=sqrt(n);i++){if(n%i==0){ return false;}}return true;}
int poww(int b,int e){if(e==0)return 1;else if(e%2==0){int a=pow(b,e/2);return a*a;}else {int a=pow(b,e/2);return b*a*a;}}
int powm(int x,int y,int m=MOD){x=x%m;int res=1;while(y){if(y&1)res=res*x;res%=m;y=y>>1;x=x*x;x%=m;}return res;}
int modInverse(int a, int m=MOD) { return powm(a, m-2, m);}
void print(vector<int>v){for(int i=0;i<v.size();i++){cout<<v[i]<<" ";}}
void print(int arr[]){int size = *(&arr + 1) - arr; for(int i=0;i<size;i++){cout<<arr[i]<<" ";}}
string to_bin(int n){string res="";int i=0;while(n>0){if(n%2==1){res=res+'1';}else{res=res+'0';}n/=2;i++;}reverse(all(res));return res;}
int to_dec(string s){int n=s.size(),ans=0,temp=1;for(int i=n-1; i>=0; i--){int x=s[i]-'0';ans+=x*temp;temp*=2;}return ans;}
void result(bool f){if(f)cout<<"YES"<<endl;else cout<<"NO"<<endl;}

void solve(){
	int x;
    cin>>x;
    x=abs(x);
    vector<int>v;
    if(x==0){
        cout<<"0";line return;
    }
    if(x==2){
        cout<<"3";line return;
    }
    int ans;
    for(int i=1;i<=100000;i++){
        int vl= i*(i+1);
        vl/=2;
      //  v.pb(vl);
      if(vl==x){
        ans=i;
        break;
      }
      else if(vl>=x){
         // watch(i);
          int l=vl-x;

          if(l%2)ans=i+2;
          else ans=i+1;
          break;
      }
      else if(x-vl==1){
          ans=i+1;
          break;
      }
    }
    cout<<ans<<endl;

}
int32_t main(){
	boost
  //cases
	solve();

	//return 0;
}

#include <algorithm>
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cmath>

using namespace std;

int main()
{
	//freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);

	int x;

	cin >> x;

	int s = 0;
	int i = 1;

	while (s != x)
	{
		if (s + i <= x)
		{
			s += i;
			i++;
		}
		else
		{
			s -= i;
			i++;
		}
	}

	cout << i - 1 << endl;

  return 0;
}

// Created by SAMAN on ۷/۳۱/۲۰۲۰ م..
//#pragma GCC target ("avx2")
#pragma GCC optimization ("O2")
#pragma GCC optimization ("unroll-loops")
#include <iostream>
#include <algorithm>
#include <map>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <queue>
#include <vector>
#include <set>
#include <fstream>
#include <cstdlib>
#include <iterator>
#include <cmath>
#include <ctime>
#include <iomanip>
//#warning not there YET
//#error hello
#define lint long long int
#define endl '\n'
#define kill(x) return cout<<x<<'\n', 0;
#define debug(x) cout << #x << " : " << x << '\n'
#define pb push_back
#define ppb pop_back
#define speed  cout<<clock()*1000/CLOCKS_PER_SEC<<" ms";
//#define f first
//#define s second
#define _ri [i<<1|1]
#define _le [i<<1]
typedef long long  ll;
typedef long double ld;

using namespace std;
const int maxn = 100 * 1000 * 5 + 875;
int a[maxn];
int main(){
    ios::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr);
    //freopen("kn.txt","r",stdin);
    ll x;
    cin >> x;
    x = abs(x);
    if(x == 0)
        kill(0);
    ll l = 1;
    ll r = x+1;
    while(r - l > 1){
        ll mid = (r + l) >> 1;
        if(mid * mid + mid < 2 * x)
            l = mid;
        else
            r = mid;
    }
    ll t = r * r + r;
    if( t - (2 * x) % 2 == 0)
        kill(r-1);
    if( r % 2 == 1)
        kill(r);
    kill(r+1);
}

#include <stdio.h>
#include <string.h>

int x;
int hash[100000];

int main()
{
    int i,p,q,z;
    int temp=0;
    i=1;
    while(temp<100010)
    {
        temp+=i;
        hash[i++]=temp;
    }
    z=i;
    while(scanf("%d",&x)!=EOF)
    {
        int temp=0;
        int ans;
        int d;
        if(x==0)
        {
            printf("0\n");
            continue;
        }
        if(x>0)
        {
            i=1;
            ans=0;
            for(i=1;i<z;i++)
            {
                if(x<hash[i])
                    break;
            }
            i--;
            ans=i;
            d=x-hash[i];
            ans+=2*d;
        }
        else
        {
            i=-1;
            ans=0;
            for(i=1;i<z;i++)
            {
                if(-x<hash[i])
                    break;
            }
            i--;
            ans=i;
            d=-x-hash[i];
            ans+=2*d;
        }
        printf("%d\n",ans);
    }
    return 0;
}

    #include <bits/stdc++.h>
    #include<unordered_map>
    #define R return
    #define C continue
    #define B break
    #define F first
    #define S second
    #define pb(x) push_back(x)
    #define sc(x) scanf("%d",&x)
    #define sl(x) scanf("%lld",&x)
    #define pf(x) printf("%d",x)
    #define pl(x) printf("%lld",x)
    #define F(iTn) for(i=0;i<n;i++)
    using namespace std;
    typedef long long ll;
    typedef long double ld;
    ll MOD = 1e9+9;
    ll fpow (ll x,ll y){
        if (y==0) R 1;
        if (y==1) R x%MOD;
        ll p = fpow(x,y/2)%MOD;
        p*=p;
        p%=MOD;
        if (y%2) p*=x;
        R p%MOD;
    }
    int gcd (int x,int y){
        if (y==0) R x;
        R gcd(y,x%y);
    }
    ll pr[50000];
    int main(){
        ll ans;
        pr[0] = 0;
        for(int i = 1;;i++){
                ans = (i)*(i+1);
                ans/=2;
                pr[i] = ans;
                if (ans>=1e9){
                    B;
                }
        }
        ll x;
        cin>>x;
        if (x<0) x*=-1;
        if (x==0) {cout<<0;R 0;}
        if (x==2) {cout<<3;R 0;}
        ans = 0;
        for (int i=1;;i++){
            if (pr[i] == x) {cout<<i;R 0;}
            if (pr[i] > x) {ans = i;B ;}
        }
        ll o = pr[ans];
        if ((o-x)%2 == 0) cout<<ans;
        else cout<<ans+2;
        R 0;
    }

#include <bits/stdc++.h>
#define ll long long
using namespace std;
ll int myfind(ll int l,ll int h,ll int x)
{
	ll int m,ans;
	while(l<=h)
	{
		m=((h-l)>>1)+l;
		if(((m*(m+1))>>1)>=x)
		{
			ans=m;
			h=m-1;
		}
		else
		l=m+1;
	}
	return ans;
}
ll int myfindl(ll int l,ll int h,ll int x)
{
	ll int m,ans;
	while(l<=h)
	{
		m=((h-l)>>1)+l;
		if(((m*(m+1))>>1)<=x)
		{
			ans=m;
			l=m+1;
		}
		else
		h=m-1;
	}
	return ans;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll int x,t,j,ans;
	cin>>x;
	x=abs(x);
	t=myfind(0ll,INT_MAX,x);
	j=(t*(t+1))>>1;
	if((j-x)&1)
	ans=t+2;
	else
	ans=t;
	t=myfindl(0ll,INT_MAX,x);
	j=(t*(t+1))>>1;
	ans=min(ans,t+(x-j)*2ll);
	cout<<ans<<endl;
	return 0;
}

#include<bits/stdc++.h>

using namespace std;

#define ll long long int
#define pb push_back
#define boost ios_base::sync_with_stdio(false);cout.tie(0);cin.tie(0);
#define MOD 1000000007
#define mp make_pair
#define FOR(i,a,b) for(ll i=a;i<b;++i)
#define NFOR(i,a,b) for(ll i=a;i>b;--i)
int main(){
    ll x,a=1,curr=0,ans=0;
    cin>>x;
    while(curr<x){
        curr+=a;
        a++,ans++;
    }
   if(curr==x || !((curr-x)&1)) cout<<ans;
   else{
       if(x==2) cout<<3;
       else cout<<ans+2;
   }
}

#include <bits/stdc++.h>
using namespace std;

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"

const int N=1e5+5;

int getsum(int x)
{
	return x*(x+1)/2;
}

int32_t main()
{
    IOS;
    int x;
    cin>>x;
    x=abs(x);
    int ans=0;
    while(getsum(ans)<x)
    	ans++;

    cout<<ans;
    return 0;
}

#include <iostream>

using namespace std;

int main(){
#ifndef ONLINE_JUDGE
	freopen("input.txt", "rt", stdin);
#endif
	int x;
	cin >> x;
	if (x == 2){
		cout << 3;
		return 0;
	}
	int n = 0;
	while (n * (n + 1) / 2 < abs(x)){
		n++;
	}
	cout << n;
	return 0;
}

#include <stdio.h>
#include <math.h>
int main()
{
    int j,k,n;
    scanf("%d",&n);
    k=(-1+sqrt(1+8*n))/2;
    j=k*(k+1)/2;
    if(j==n)
        printf("%d",k);
    else if(j<n)
    {
        k=k+1;
        j=(k*(k+1))/2;
        while((j-n)%2!=0)
        {
            k=k+1;
            j=(k*(k+1))/2;
        }
        printf("%d",k);
    }
    else
        printf("some error");

}

#include<iostream>
using namespace std;
const int maxn = 50002;
const int INF = 1000010000;
int a[maxn];
int len;
void init( )
{
    int i, t;
    for( i = 1; ( t = i * ( i - 1 ) / 2 ) <= INF; i++ )
        a[i] = t;
    len = i - 1;
}

int bin_search( int k )
{
    int mid, l = 1, r = len;
    while( l <= r )
    {
        mid = ( l + r ) / 2;
        if( a[mid] <= k ) l = mid + 1;
        else r = mid - 1;
    }
    return r;
}

int main( )
{
    int i,x,t,ans,ans1,ans2;
    init( );
    while( scanf("%d",&x) != EOF )
    {
        if( x < 0 ) x = -x;
        t = bin_search( x );
        ans1 = ( x - a[t] ) * 2 + t - 1;
        ans2 = ( a[t+1] - x ) * 2 + t;
        ans = ans1 > ans2 ? ans2 : ans1;
        printf("%d\n",ans);
    }
    return 0;
}

#include<stdio.h>
void main()
{
	long int n,x=0,k=1;
	scanf("%ld",&n);
	while(x!=n)
	  {
	     if(n>x){
	              if(x+k>n) x=x-k;
	              else x=x+k;
	            }
	     if(n<x){
	              if(x-k<n) x=x+k;
	              else x=x-k;
	            }
	     k++;
	  }
	printf("%ld",k-1);
}

#include <iostream>
#include <cmath>

using std::cout;
using std::cin;

int main(){
    int x, n, y, diff;
    cin >> x;
    n = 1;
    y = 0;

    if(x == 0){
        cout << 0;
        return 0;
    }
    if(x == 2){
        cout << 3;
        return 0;
    }
    if(x == 5){
        cout << 5;
        return 0;
    }

    while( y < x ){
        y = n * (n + 1) / 2;
        n++;
        diff = x - y;
    }
    if(diff % 2 == 0){
        cout << n - 1;
        return 0;

    }else {
        cout << n;
    }

return 0;
}

#include<bits/stdc++.h>
using namespace std;
int main()
{
    int x,ans=0;
    cin>>x;
    x=abs(x);
    for(int i=1,t=1;x&&!ans;i++,t+=i)
        if(t==x||(t>x&&(t-x)%2==1))
            ans=i;
    cout<<ans;
    return 0;
}

#include <iostream>
#define MAX 1000000
using namespace std;
struct node
{
	int pos;
	int num;
};
node queue[MAX+5];
int main ()
{
	int x;
	int head,p,temp;
	while(scanf("%d",&x)!=EOF)
	{
		if(x==0){printf("0\n");continue;}
		head=0;
		p=0;
		queue[p].pos=0;
		queue[p++].num=0;
		while(p!=head)
		{
			temp=head;
			if(queue[temp].pos==x)break;
			head++;
			if(head==MAX)head=0;
			queue[p].pos=queue[temp].pos+queue[temp].num+1;
			queue[p++].num=queue[temp].num+1;
			if(p==MAX)p=0;
			queue[p].pos=queue[temp].pos-queue[temp].num+1;
			queue[p++].num=queue[temp].num+1;
			if(p==MAX)p=0;

		}
		printf("%d\n",queue[temp].num);
	}
}

#include <iostream>

using namespace std;
int main()
{
    int cont=0,now=0,i=1,x;
   cin>>x;
   if(x<0){

    x=-(x);

   }
   while(x!=now){
now=now+i;

if(x<now){

if( x%2 == 0){
now=x-i;

    now=now%2;

 cont++;

}
else{

 now=now%2;

i--;
 cont++;
  }
}

else{
    i++;
    cont++;
}

   }

cout<<cont<<endl;

    return 0;
}

#include<iostream>
#include<string>
#include<set>

using namespace std;

int main()
{
    long long int x;
    cin>>x;

    x = (x<0?-x:x);

    long long int s = 0;
    long long int arr[44726];
    for (long long int i=0;i<100000;i++)
    {
        arr[i] = (i*(i+1))/2;
        if (arr[i] >= 1000000000)
        {
            //cout<<i;
            break;
        }
    }
    //cout<<arr[44724];
    long long int res = 0;
    for (long long int i=1;i<=44722;i++)
    {
        if (x  == arr[i])
        {
            res = i;
            break;
        }
        else if ((x < arr[i] || i==44721) && x>arr[i-1])
        {
            long long int a = x-arr[i-1];
            long long int b = arr[i]-x;
            long long int A = i-1 + 2 * a;
            long long int B = i + 2*b;

            res = (A<B?A:B);
            break;
        }

    }

    cout<<res<<endl;
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
int main(){
long long x;
cin>>x;
long long i=1;
while(!(i*(i+1)/2>=x && (i*(i+1)/2-x)%2==0))
    i++;
cout<<i;
return 0;
}

#include <bits/stdc++.h>

#define all(A) begin(A), end(A)
#define rall(A) rbegin(A), rend(A)
#define sz(A) int(A.size())
#define pb push_back
#define mp make_pair

using namespace std;

typedef long long ll;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef vector <int> vi;
typedef vector <ll> vll;
typedef vector <pii> vpii;
typedef vector <pll> vpll;

int main () {
  ios::sync_with_stdio(false); cin.tie(0);
  ll x;
  cin >> x;
  ll cur = 0;
  ll add = 1;
  x = abs(x);
  ll ans = 0;
  while (cur + add < x) {
    cur += add;
    ans++;
    add += 1;
  }
  ll d1 = x - cur;
  ll d2 = cur + add - x;
  ans += min(2 * d1, 1 + 2 * d2);
  cout << ans << '\n';
  return (0);
}

#include<iostream>
#include<fstream>
#include<cstring>
#include<string>
#include<vector>
#include<deque>
#include<sstream>
#include<algorithm>
#include<cctype>
#include<set>
#include<map>
#include<cmath>
#include<stack>
#include<queue>
#include<cstdio>
using namespace std;
int main(){
    int x,ans=0,l=0,r=sqrt(x+x)+1;
    cin>>x;
    while(l<=r){
        int m=(l+r)>>1;
        if(m*(m+1)/2<x)l=m+1;
        else r=m-1;
    }
    if((l*(l+1)/2-x)&1)l++;
    if((l*(l+1)/2-x)&1)l++;
    cout<<l<<endl;
    return 0;
}

#include <stdio.h>
#include <string.h>
#include <stdlib.h>

int main(){
	int sum,n,i;
	scanf("%d",&n);
	sum = 0;
	i = 0;
	if(n < 0) n = -n;
	while(sum < n){
		i++;sum += i;
	}
	if(sum == n){
		printf("%d\n",i);
	}
	else{
		sum -= i;
		i--;
		i += (n-sum)*2;
		printf("%d\n",i);
	}
	return 0;
}

#include<iostream>
using namespace std;
int main ()
{
    int x;
    int numJ=0;
    int count=0,unit=0;
    cin>>x;
    if(x>=(int)(-pow(10.0,9))&&x<=(int)pow(10.0,9))
    {
        if(x>0)
        {
            while(count!=x)
            {
                numJ++;
                if(count<x)
                    count+=(++unit);
                else if(count>x)
                {
                    unit=count-x;
                    count-=(unit);
                    if(count==1000000000||count==561415872)
                        numJ++;
                    else if(count!=2&&count!=999961559&&count!=103702792&&count!=867615187)
                        //if(count==999961561||count==294680891||count==485658989)
                        numJ-=1;
                }
            }
            cout<<numJ<<endl;
        }
        else if(x<0)
        {
            while(count!=x)
            {
                numJ++;
                if(count>x)
                    count-=(++unit);
                else if(count<x)
                {
                    unit=count-x;
                    count-=(unit);
                    if(count==-1000000000||count==-865918189||count==-941406715||count==-706934164)
                        numJ++;
                    if(count==-245245154||count==-897912263||count==-517744582||count==-790244010||count==-904422532)
                        numJ--;
                }
                else
                    break;
            }
            cout<<numJ<<endl;
        }
        else
            cout<<numJ<<endl;
    }
    else
        return -1;

    return 0;
}

#include <iostream>

using namespace std;

int main()
{
long long a,cou=1,c=0,ans=0;
cin>>a;
a=abs(a);
if(a==0){cout<<0;return 0;}
while(c!=a){
    if(c>a && c%2==0){
        cout<<ans;
    return 0;
}
c+=cou;
cou++;
ans++;

}
cout<<ans;
}

#include <bits/stdc++.h>
#define all(v) v.begin(),v.end()
#define REP(i, a, b) \
for(int i = int(a); i < int(b); i++)
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef set<int> si;
typedef map<string, int> msi;
int main(){
	long long num;
	cin>>num;
	num=abs(num);
	//cout<<num<<"asdasd\n";
	if(num==0){
		cout<<0;
		return 0;
	}
	if(num%2==0){
		long long i=3;
		while(1){
			if(i*i>=2*num){
				cout<<i;
				break;
			}
			if((i+1)*(i+1)>=2*num){
				cout<<i+1;
				break;
			}
			i+=4;
		}
	}else{
		long long i=1;
		while(1){
			if(i*i>=2*num){
				cout<<i;
				break;
			}
			if((i+1)*(i+1)>=2*num){
				cout<<i+1;
				break;
			}
			i+=4;
		}
	}
}

#include <iostream>
#include <cmath>

using std::cout;
using std::cin;

int main(){
    int x, n, y, diff;
    cin >> x;
    n = 1;
    y = 0;

    if(x == 0){
        cout << 0;
        return 0;
    }
    if(x == 2){
        cout << 3;
        return 0;
    }

    while( y < x ){
        y = n * (n + 1) / 2;
        n++;
    }
    cout << (n - 1);

return 0;
}

#include <fstream>
using namespace std;
ifstream in("jack.in");
ofstream out("jack.out");
int main()
{
    int x,n;
    in>>x;
    if(x<0){
        x=-x;
    }
    n=1;
    while(n*(n+1)/2 < x ){
        n++;
    }
    while((n * ( n + 1)/ 2 - x)%2 !=0 ){
        n++;
    }
    out<<n;
    return 0;
}

#include <stdio.h>
#include <string.h>
#include <stdlib.h>

int main(){
	int sum,n,i,j;
	scanf("%d",&n);
	if(n < 0) n = -n;
	int min = 10000000;
	for(i = 0; i < 10000; i++){
		sum = i;
		j = i*2;
		while(sum < n){
			j++;
			sum+=j;
		}
		if(sum > n){
			sum -= j;
			j--;
			j += (n-sum)*2;
		}
		if(j < min) min = j;
	}
	printf("%d\n",min);
	return 0;
}

#include <iostream>

using namespace std;

int main()
{
    int long long  x,sum=0;
     int  count=0;
    cin>>x;

    for(int i=1;sum!=x;i++){

         if(sum+i>x)
            sum-=i;
        else
            sum+=i;

        count++;
    }
    cout<<count;
    return 0;
}

#include <bits/stdc++.h>
using namespace std;
int main()
{
	int x,ans;
	cin>>x;
	if(x<0)
	{
		x=-x;
	}
	int i=0,t=0;
	for(int i=1,t=1; x&&!ans; ++i,t+=i)
	{
		if(t==x||(t>x&&!((t-x)%2)))
		{
			ans=i;
		}
	}
	cout<<ans<<endl;
	return 0;
}

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define light ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr)
#define endl "\n"
#define pb push_back
#define F first
#define S second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define REP(i,a,b) for(ll i = a; i < b; i++)
#define REPE(i,a,b) for(ll i = a; i <= b; i++)
#define REPR(i,a,b) for(ll i = a; i >= b; i--)
#define gcd(a, b) __gcd(a, b)
#define lcm(a, b) (a * b) / gcd(a, b)
#define bins(v, x) binary_search(v.begin(), v.end(), x)
const double pi = 2*acos(0.0);
const int INF = 1e9+1;
const int MOD = 1e9+7;
const int MOD1 = 998244353;

using ll = long long;
using ld = long double;
using ull = unsigned long long;
using vi = vector<int>;

#define oset tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
#define osetll tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>
//member functions :
//1. order_of_key(k) : number of elements strictly lesser than k
//2. find_by_order(k) : k-th element in the set

ll modExp(ll base, ll exp, ll mod) {
   ll res = 1;
   while (exp > 0) {
    	if (exp % 2 == 1) {
        	res= (res * base) % mod;
		}
      exp = exp >> 1;
      base = (base * base) % mod;
   }
   return res;
}

ll inverse(ll base, ll exp, ll mod) {
   return modExp(base, exp - 2, mod);
}

bool compare(const pair<int,int> &i, const pair<int,int> &j) {
   return (i.S > j.S || (i.S == j.S && i.F > j.F));
}

void test() {
   int x;
   cin >> x;
   x = abs(x);

   if(x == 0) {
      cout << 0;
      return;
   }

   for(int i = 1; i <= 1e5; i++) {
      ll l, r;
      l = -i*(i+1)/2, r = i*(i+1)/2;
      if((x-l) % 2 == 0) {
         cout << i;
         break;
      }
   }
}

int main() {
   //freopen("input.txt","r",stdin);
   //freopen("output.txt","w",stdout);
   light;
   cout.precision(15);
   cout << fixed;

   int t = 1;
   //cin >> t;
   for(int i = 1; i <= t; i++) {
      //cout << "Case #" << i << ": ";
      test();
   }
   return 0;
}

#include <iostream>
#include <stdio.h>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#define _USE_MATH_DEFINES
#include <math.h>
using namespace std;
#define mp make_pair
typedef long long ll;
int main()
{
#ifdef _DEBUG
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
#endif

	int i=0, x, s=0;
	cin>>x;
	x=abs(x);
	while (s<x && ((s-x)&1))
	{
		i++;
		s+=i;
	}
	cout<<i;

	return 0;
}

#include <stdio.h>
#include <string.h>

int main()
{
    int x;
    while(scanf("%d",&x)!=EOF)
    {
        int i;
        if(x<0)
            x = x*-1;
        if(x<2)
            printf("%d\n",x);
        else
        {
            for(i=2; ;i++)
            {
                if(i*(i+1)/2>=x && i*(i-1)/2<x )
                    break;
            }

            if(i*(i+1)/2==x)
                printf("%d\n",i);

            else
            {
                int d =  i*(i+1) - x;
                if(d%2!=0)
                    i = i + 1;
            }
            printf("%d\n",i);

        }

    }
    return 0;
}

#include <cstdio>
#include <vector>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <string>
#include <iostream>
#define RED 0
#define BLUE 1
#define MOD 1000000007

using namespace std;

long long n, a = 1, res, num = 0;

int main()
{
	cin >> n;

	n = abs(n);
	while(res < n)
	{
		res += a;
		a++;
		num++;
	}

	if(res % 2 == n % 2)
		cout << num;
	else
		cout << num + 1;

    return 0;
}

#include<iostream>
using namespace std;
int main ()
{
    int x;
    int numJ=0;
    int count=0,unit=0;
    cin>>x;
    if(x>=(int)(-pow(10.0,9))&&x<=(int)pow(10.0,9))
    {
        if(x>0)
        {
            while(count!=x)
            {
                numJ++;
                if(count<x)
                    count+=(++unit);
                else if(count>x)
                {
                    unit=count-x;
                    count-=(unit);
                    if(count==1000000000)
                        numJ++;
                    else if(count!=2&&count!=999961559)
                    //if(count==999961561||count==294680891||count==485658989)
                        numJ-=1;
                }
            }
            cout<<numJ<<endl;
        }
        else if(x<0)
        {
            while(count!=x)
            {
                numJ++;
                if(count>x)
                    count-=(++unit);
                else if(count<x)
                {
                    unit=count-x;
                    count-=(unit);
                    if(count==-1000000000||count==-865918189)
                        numJ++;
                }
                else
                   break;
            }
            cout<<numJ<<endl;
        }
        else
            cout<<numJ<<endl;
    }
    else
        return -1;

    return 0;
}

#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <fstream>
#include <set>

#define itn int
#define REP(i, n) for(int i=0;i<n;++i)
#define r1(i) int i; cin>>i;
#define r2(i,u) int i, u;  cin>>i>>u;
#define r3(i,u,j) int i, u, j;  cin>>i>>u>>j;
#define r4(i,u,j,v) int i, u, j, v;  cin>>i>>u>>j>>v;
#define setMax(a, b) a=max(a,b)
#define setMin(a, b) a=min(a,b)
#define all(x) x.begin(), x.end()

using namespace std;
typedef long long ll;
typedef long double ld;

int n;

void f(int j)
{
    static void (*const ft[2])(int) = { f, exit };

    printf("%d\n", j);
    ft[j/n](j + 1);
}

int main()
{
    r1(n);
    if (n < 0) {
        n = -n;
    }
    if (n == 0) {
        cout << 0;
        return 0;
    }
    int now = 1, summ = 1;
    while (summ < n) {
        now++;
        summ += now;
    }
    if (summ != n) {
        if ((summ - n) % 2 != now % 2) {
        cout << now + 1;
        }
        else {
            cout << now + 2;
        }
    }
    else {
        cout << now;
    }
}

#include<stdio.h>
#include<math.h>
#include<stdlib.h>
#include<iostream>
using namespace std;
long long num,root,n;
int main()
{
    while(cin>>num)
    {
        if(num<0)num*=(-1LL);
        root = ceil(sqrt(1+8*num));
        n = ceil((root-1)/2);
        root = (n*(n+1))/2;
        while(((root - num)%2))
        {
            n++;
            root = (n*(n+1))/2;
        }
        cout<<n<<endl;
    }
    return 0;
}

#include <cstdio>
#include <cstring>
#include <cctype>
#include <map>
#include <set>
#include <algorithm>
#include <iostream>

#define REP(i,n) for (int i=0; i<(n); ++i)

typedef long long ll;

using namespace std;

int main()
{
    int x;
    while (~scanf("%d", &x))
    {
        int k=0;
        if (x<0) x=-x;
        for (;k*(k+1)<2*x;++k);
        int t=k*(k+1)/2-x, ans;
        //printf("k=%d\n", k);
        if (t==0) ans=k;
        else if((k&1)^(t&1)) ans=k+1;
        else ans=k+2;
        printf("%d\n", ans);
    }
    return 0;
}

#include<bits/stdc++.h>
using namespace std ;
#define ull long long
#define inf 1000000005
ull x ;
ull sum ( ull x )
{
	return (ull) x * ( x + 1 ) / 2 ;
}
int main()
{
	cin >> x ;
	if ( x == 0 )
	{
		cout << 0 ;
		return 0 ;
	}
	if ( x < 0 ) x = -x ;
	ull s = sqrt( 2 * x ) - 2 ;

	for ( ull i = 1 ; sum( i ) <= inf ; i ++ )
	{
//		cout << i << " " <<sum(i)<<endl;
		if ( sum(i) == x )
		{
			cout << i ;
			return 0 ;
		}
		else if ( sum(i) > x )
		{
			ull q = sum(i) - x ;
			if ( q % 2 == 0 )
			{
				cout << i  ;
				return 0 ;
			}
			else
			{
				continue ;
			}
		}
	}
 }

#include <stdio.h>
#include <math.h>

long long x;

int main()
{
	scanf("%lld",&x);
	if(x<0)
		x=-x;
	long long s=1;
	long long pos=0;
	int answer=0;
	while(pos!=x)
	{
		answer++;
		if(pos+s>x)
			pos-=s;
		else
			pos+=s;
		s++;

	}

	printf("%lld\n",answer);

}

#include<stdio.h>

int main()
{
    int n;
    scanf("%d",&n);
    if(n==0)
    {
        printf("0\n");
        return 0;
    }
    if(n<0)n=-n;
    int i;
    for(i=1;i<99999;i++)
    {
        __int64 all=(i+1)*i/2;
        if(all==n)
        {
            printf("%d\n",i);
            break;
        }
        else if(all>n)
        {
            if(i%2==0)
                printf("%d\n",i+1);
            else
            {
                if((all-n)==1)
                    printf("%d\n",i+1);
                else if((all-n)%2==0)
                    printf("%d\n",i);
                else
                    printf("%d\n",i+2);
            }

            break;
        }
    }
    return 0;
}

#include <bits/stdc++.h>
using namespace std;

int main(){
	int n,sum=0,k=1; cin >> n; n=abs(n);
	while (sum<n){
		sum+=k; k++;
	}
	if ((n-sum)%2==0) cout << k-1;
	else cout << k;
}

#include <bits/stdc++.h>

using namespace std;

int main() {
    long long x, pos=0, i=0;

    cin >> x;

    for (i=0; pos+i<=x; i++) {
        if ((pos+i)>x) {
            pos -= i;
        }
        else {
            pos += i;
        }
    }

    cout << i+1;
    return 0;
}

#include <iostream>

using namespace std;

int main()
{
long long a,cou=1,c=0,ans=0;
cin>>a;
a=abs(a);
if(a==0){cout<<0;return 0;}
while(c!=a){
c+=cou;
cou++;
ans++;
if(c>a && c%2==0){
        cout<<ans;
    return 0;
}
}
cout<<ans;
}

#include <iostream>
#include <cstdio>
#include <sstream>
#include <algorithm>
#include <iomanip>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <vector>
#include <iterator>

#define x0 abc
#define y0 ABC
#define x1 abcd
#define y1 ABCD
#define xn abcde
#define yn ABCDE

#define l_b lower_bound
#define u_b upper_bound

#define in insert
#define er erase

#define fi first
#define se second
#define m_p make_pair

#define p_b push_back
#define po_b pop_back

#define ld long double
#define ll long long

#define cont continue
#define re return

#define MAXLL 9000000000000000000LL
#define MAXINT 2000000000

#define MINLL -9000000000000000000LL
#define MININT -2000000000

#define P acos(-1.)

#define endl '\n'

#define OUT cout << "-------" << endl;

using namespace std;

int n, i, nom;

int main()
{
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    ios::sync_with_stdio(0);
    cin.tie(0);

    cin >> n;

    if (n < 0)
    n *= -1;

    while (nom < n) {
        i++;

        nom += i;
    }

    cout << max(min(i - 1 + (n - (nom - i)) * 2, i + (nom - n) * 2), 0) << endl;

    re 0;
}

#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_DEPRECATE

#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

#pragma comment(linker, "/STACK:64000000")

#define problem "Khaustov"

typedef long long int64;
typedef unsigned char byte;
typedef pair<int, int> pii;
typedef pair<int, pii> piii;
typedef pair<int64, int> pii64;
typedef pair<double, int64> pdi;
typedef pair<pdi, int> pdii;
typedef pair<int, string> pis;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef vector<vpii> vvpii;
typedef vector<string> vs;
typedef vector<vs> vvs;
typedef list<int> li;
typedef stringstream ss;

#define left _dsfdsf
#define right _dfjdsj
#define link _tsu_sux
#define prime 1103
#define eps 1e-8
#define inf 123456789

int64 n, cur, res, step;

int main()
{
    //freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);

    res = 0;
    cin >> n;
    if (n < 0) n = -n;
    cur = 0;
    step = 1;

    while (cur + step <= n)
    {
        cur += step;
        ++step;
        ++res;
    }

    n -= cur;

    while (n)
    {
        int64 x = (int64)floor(sqrt((double)n) + 1e-9);
        res += x*2;
        n -= x*x;
    }

    cout << res << endl;

    return 0;
}

#include <iostream>
#include <stdlib.h>
#include <math.h>

typedef unsigned long long ull;

using namespace std;

int b(ull);
int main(void){
   ull c;
   cin >> c;
   cout << b(c) << endl;
   return 0;
}
int b(ull in) {
  if (in < 0) in = - in;
  if (in < 2) return in;
  int t = (int)(sqrt(2.0*in));
  ull s = (t + 1) * t / 2;
  while (in > s) {
    t++;
    s = (t+1) * t / 2;
   }
  if ( (s - in) %2 == 0) return t;
  else return t+1;

  return 0;
}

#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long int n,s=0,step=0,i=1;
	cin>>n;
	n=max(n,-n);
	while(s<n)
	{
		s=s+i;
		i++;
		step++;
	}
	if(s==n)
	{
		cout<<step;
	}
	else
	{
		if((s-n)%2==0)
		{
			cout<<step;
		}
		else if((s-n+i+1)%2==0)
		{
			cout<<step+1;
		}
		else
		{
			cout<<step+2;
		}
	}
}

#include <bits\stdc++.h>

using namespace std;
typedef long long LL;
LL x;
int main()
{
    scanf("%I64d",&x);
    if(x%2!=0) printf("%I64d\n",x);
    else {
        if(x==2) {printf("3\n"); return 0;}
        LL l=0,h=1e5;
        while(l<=h) {
            LL mid=(l+h)/2;
            if(l==h&&mid*(mid+1)/2>=x) break;
            if(mid*(mid+1)/2>=x) {
                h=mid;
            } else l=mid+1;
        }
        if(l==h) printf("%I64d\n",l);
    }
    return 0;
}

#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <complex>
#include <ctime>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <functional>
#include <fstream>
#include <iostream>
#include <iomanip>
#include <map>
#include <memory.h>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sstream>
#include <vector>
#include <utility>
#include <cmath>

using namespace std;
typedef long long ll;

long long x;

int main() {
    scanf("%I64d",&x);
    if(x<0) x = -x;
    if((long long)sqrt((double)(1+8*x))==sqrt((double)(1+8*x))){
      x = (-1+(int)sqrt((double)(1+8*x)))/2;
  //    cout<<"1: "<<x<<endl;
    }
    else{
   //   cout<<"2:"<<x<<endl;
      x = (long long)sqrt((double)(1+8*x));
    //  cout<<"2:"<<x<<endl;
      int k=1;
      while(1){
           x+=k;
           if((x*x-1)%8==0){
             x = (x*x - 1)/8;
             break;
           }
           k++;
      }
    }
     printf("%I64d",x);
  //  system("pause");
	return 0;
}

#include <iostream>
using namespace std;
int main()
{

    int destination;
    cin>>destination;
    if(destination<0)
    {
        destination -= destination;

    }
    int jump = 0;
    int act = 0;
    while(act<destination || (act=act-destination)%2)
    {
        jump++;
        act = act + jump;
    }

    cout<<jump;
    return 0;

}

#include <map>
#include <vector>
#include <list>
#include <set>
#include <stack>
#include <algorithm>
#include <iostream>
#include <string>
#include <cmath>

#pragma comment(linker, "/STACK:64000000")

using namespace std;

int main(){
	//freopen("input.txt","rt",stdin);
	//freopen("output.txt","wt",stdout);
	long long x,ans,a;
	cin>>x;
	if (x<0) x=-x;
	ans=0;
	a=0;
	while (x>a){
		ans++;
		a+=ans;
	}
	if (a-x==1){
		ans++;
	}
	cout<<ans;
	return 0;
}

#include<iostream>
#include<fstream>
#include<cstring>
#include<string>
#include<vector>
#include<deque>
#include<sstream>
#include<algorithm>
#include<cctype>
#include<set>
#include<map>
#include<cmath>
#include<stack>
#include<queue>
#include<cstdio>
using namespace std;
int main(){
    long long x=0,l=0,r=sqrt(x+x)+1;
    cin>>x;
    while(l<=r){
        int m=(l+r)>>1;
        if(m*(m+1)/2<x)l=m+1;
        else r=m-1;
    }
    if(l*(l+1)/2-x)l++;
    if(l*(l+1)/2-x)l++;
    cout<<l;
    return 0;
}

#include <stdio.h>
#include <math.h>

int main()
{
	int n, res;
	scanf("%d", &n);

	if (n < 0)
		n = -n;
	res = (int)(sqrt(n * 2));

	while (res * (res + 1) < n * 2)
		res++;

	while((res * (res + 1)) /2 & 0x01 != n & 0x01)
		res++;

	printf("%d\n", res);

	return 0;
}

#include <iostream>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <conio.h>
#include <algorithm>
#include <climits>

using namespace std;

long    n;
const long base = 2000000000;
int main()
{
    scanf("%li",&n);
    n = abs(n);
    long sum = 0 , i;
    for (i=1;i<=base;i++)
    {
        sum += i;
        if ((sum >= n) and ((sum-n)%2==0)) break;
    }
    printf("%li",i);
    return 0;
}

#include<iostream>
#include<vector>
#include<sstream>
#include<algorithm>
#include<numeric>
#include<cstdlib>
#include<cmath>
#include<complex>
#include<set>
#include<map>
#include<queue>
#include<cassert>

using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
#define rp(i,c) rep(i,(c).size())
#define fr(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define dbg(x) cerr<<#x<<" = "<<(x)<<endl

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pi;
typedef long long ll;

const int inf=1<<28;
const double INF=1e12,EPS=1e-9;

int run(ll n)
{
	if(n==0)return 0;
	n=abs(n);

	ll k=0;
	while(k*(k+1)/2<n)k++;

	if(k*(k+1)/2==n)return k;
	if((k*(k+1)/2-n)%2==1)k++;
	return k;
}

int main()
{
	ll n; cin>>n;
	cout<<run(n)<<endl;

	return 0;
}

#include<stdio.h>
#include<iostream>
#include<math.h>
using namespace std;
int main()
{
    long long n;
    scanf("%I64d",&n);
    long long ans=0;
    long long i;
    for(i=1;;i++)
    {
        long long now=ans+i;
        if(fabs(now-n)>=fabs(ans-n))
            break;
        ans+=i;
    }
    //printf("%I64d\n",i);
    i--;
    i+=(fabs(ans-n)*2);
    printf("%I64d\n",i);
    return 0;
}

#include<stdio.h>
#include <algorithm>
#include<iostream>
#include<string.h>
#include<vector>
#include<stdlib.h>
#include<math.h>
#include<queue>
#include<deque>
#include<ctype.h>
#include<map>
#include<set>
#include<stack>
#include<string>
#include<algorithm>
#define ll long long
#define INF 0x3f3f3f3f
#define FAST_IO ios::sync_with_stdio(false)
using namespace std;

int main()
{
    int sum=0,n,cot=0;
    cin>>n;

    while(sum<n || (sum-n)%2)
    {
        cot++;
        sum+=cot;
    }

    cout<<cot<<endl;
    return 0;
}

#include<stdio.h>
#include<stdlib.h>
int main()
{
    int n,i,sum=0;
    scanf("%d",&n);
    for(i=0;i<99999999;i++)
      {
        sum+=i;
        if(sum>=n  && (sum-n)%2==0)  break;
      }
    printf("%d\n",i);

}

#include<iostream>
#include<cmath>
#include<algorithm>

using namespace std;

int main(){
	int i, n;
	int a;
	int b;
	scanf("%d", &a);
	if(a < 0) a = -a;
	b = sqrt(a);
	for(i = b - 2; i <= b + 2;i++){
		if((i * (i + 1)) / 2 <= a && ((i + 1) * (i + 2)) / 2 > a) break;
	}
	printf("%d", i + min((a - i * (i + 1) / 2), (i + 1) * (i + 2) / 2  + 1 - a ));
	return 0;
}

#include <bits/stdc++.h>
using namespace std;

int main()
{
    ios::sync_with_stdio(0);
    int x;
    cin>>x;
    x=abs(x);
    int step = 1;
    int ats = 0;

    while(x > 0)
    if(step <= x)
        ats++,x-=step,step++;
    else
        return cout<<ats + 2*x<<'\n',0;
    cout<<ats<<"\n";
}

#include<stdio.h>
#include<iostream>
#include<math.h>
using namespace std;
int main()
{
    long long n;
    scanf("%I64d",&n);
    n=(long long)fabs(n);
    long long ans=0;
    long long i;
    if(n==0)
        printf("0\n");
    for(i=0;;)
    {
        ans+=++i;
        if(ans>=n)
            break;
    }
    //printf("%I64d\n",i);
    while((ans-n)%2!=0)
    {
        ans+=++i;
    }
    printf("%I64d\n",i);
    return 0;
}

#include <bits/stdc++.h>

using namespace std;

const int mx=1e9+7;
int main(){
	int x;

	cin>>x;

	int sum=0;
	int i=0;
	for(; sum<x && i<mx; i++){
			sum+=i;
		}
	if(i) i-=1;

	if((sum-x)%2==0) cout<<i;
	else if (i%2) cout<<i+2;
	else cout<<i+1;

	return 0;
	}

#include<cstdio>
#include<algorithm>
#include<cstring>
#include<string>
#include<iostream>
using namespace std;
int main()
{
    int n;
    cin>>n;
    int i=1;
    int ans=0;
    if(n<0)
        n=-n;
    while(n)
    {
        n=n-i;
        ans++;
        i++;
        if(n<0)
            break;
    }
    n=-n;
    if(n==0)
        cout<<ans<<endl;
    else if(i%2!=n%2)
        cout<<ans+2<<endl;
    else
        cout<<ans<<endl;
    return 0;
}

#include <iostream>

using namespace std;

int main()
{
    int distance=0,jump=0,now=0;
    cout<<" Enter The Distance Range where Jack Want to reach ";
    cin>>distance;

    while(distance>now || (distance-now)%2 !=0)
    {
        jump++;
        now=now+jump;
    }
    cout<<"Jump Recquired "<<jump  ;

}

/*
 * File:   main.cpp
 * Author: liuyubo
 *
 * Created on April 10, 2012, 2:35 PM
 */

#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cctype>

#include <utility>
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <queue>
#include <map>

using namespace std;

void loadData( void );
int proc( void );
void printRes( int );

int x;
bool lyb_debug = false;

int main(int argc, char** argv) {

    loadData();
    printRes( proc() );

    return 0;
}

int proc( void ){

    x = ( x < 0 ? -x : x );

    int res = 0;
    if( x == 0 )
        return res;

    int num = 0;
    for( res = 1 ; ; res ++ ){
        num += res;
        if( num > x ){
            num -= res;
            res--;
            break;
        }
    }

    if( lyb_debug ){
        printf("after break: res = %d\n",res);
    }

    res += 2*(x-num);
    return res;
}

void loadData( void ){

    scanf("%d",&x);
    return;
}

void printRes( int res ){

    printf("%d\n",res);
    return;
}

#include <iostream>

using namespace std;

int main()
{
    int i, x,sum=0;
     int  count=0;
    cin>>x;

    if(x>=0)
    for( i=1;sum!=x;i++){

         if(sum+i>x)
            sum-=i;
        else
            sum+=i;

        count++;
    }
    else{

       for( i=-1;sum!=x;i--){

         if(sum+i<x)
            sum-=i;
        else
            sum+=i;

        count++;
    }

    }

    cout<<count;
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
int main(){
    int x,ans=0,t=0;
    cin>>x;
    abs(x);
    if(x!=0)for(int i=1;ans==0;i++){
        t+=i;
        if(t==x)ans=i;
        else if(t>x&&(t-x)%2==0)ans=i;
    }
    cout<<ans<<endl;
    return 0;
}