#include <map>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <stack>
#include <cctype>
#include <cstdio>
#include <string>
#include <vector>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iomanip>
#include <numeric>
#include <sstream>
#include <utility>
#include <iostream>
#include <algorithm>
using namespace std;
class AliceGameEasy {
public:
long long findMinimumValue( long long x, long long y )
{
long long sum = x + y;
long long root = (long long) sqrt(1 + 8 * sum);
if(root * root != 1 + 8 * sum)
return -1;
long long round = (-1 + root) / 2;
long long sol = 0;
long long s = 0;
if(round == 0 || x == 0)
return 0;
for(int i=round;i>=1;i--)
{
if(s + i >= x)
return sol + 1;
else
{
s += i;
sol ++;
}
}
return -1;
}
};
int main()
{
AliceGameEasy obj;
cout << obj.findMinimumValue( 0, 1) << endl;
return 0;
}
I2luY2x1ZGUgPG1hcD4gIAojaW5jbHVkZSA8Y21hdGg+ICAKI2luY2x1ZGUgPGN0aW1lPiAgCiNpbmNsdWRlIDxkZXF1ZT4gIAojaW5jbHVkZSA8cXVldWU+ICAKI2luY2x1ZGUgPHN0YWNrPiAgCiNpbmNsdWRlIDxjY3R5cGU+ICAKI2luY2x1ZGUgPGNzdGRpbz4gIAojaW5jbHVkZSA8c3RyaW5nPiAgCiNpbmNsdWRlIDx2ZWN0b3I+ICAKI2luY2x1ZGUgPGNsaW1pdHM+ICAKI2luY2x1ZGUgPGNzdGRsaWI+ICAKI2luY2x1ZGUgPGNzdHJpbmc+ICAKI2luY2x1ZGUgPGZzdHJlYW0+ICAKI2luY2x1ZGUgPGlvbWFuaXA+ICAKI2luY2x1ZGUgPG51bWVyaWM+ICAKI2luY2x1ZGUgPHNzdHJlYW0+ICAKI2luY2x1ZGUgPHV0aWxpdHk+ICAKI2luY2x1ZGUgPGlvc3RyZWFtPiAgCiNpbmNsdWRlIDxhbGdvcml0aG0+ICAKCnVzaW5nIG5hbWVzcGFjZSBzdGQ7IAoKY2xhc3MgQWxpY2VHYW1lRWFzeSB7IApwdWJs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