#include<stdio.h>
long long num,min,mini;
long long work(long long n,long long hm,long long time)
{
    //printf("work %lld != %lld %lld %lld\n",num,n,hm,time);
    if(n==num) return time-1;
    if(n+time>num) return 0;
    long long c= work(n+time,hm+1,time+1);
    long long d= work(n,hm,time+1);
    if(d<=0)
    {
        //printf("return c= %lld\n",c);
        return c;
    }
    else if(c<=0)
    {
        //printf("return d= %lld\n",d);
        return d;
    }
    else if(c>d) return d;
    return c;
}
main()
{
    scanf("%lld",&num);
    printf("%lld\n",work(0,0,1));
}
