//by yjz
#include<bits/stdc++.h>
using namespace std;
#define FF first
#define SS second
#define PB push_back
#define MP make_pair
#define foreach(it,s) for(__typeof((s).begin()) it=(s).begin();it!=(s).end();it++)
#ifndef LOCAL
#define cerr if(0)cout
#endif
typedef long long ll;
const int mod = 1e9+7;
//My i/o stream
struct fastio
{
	char s[100000];
	int it, len;
	fastio() {it=len=0;}
	inline char get()
	{
		if (it<len) return s[it++]; it=0;
		len=fread(s, 1, 100000, stdin);
		if (len==0) return EOF; else return s[it++];
	}
	bool notend()
	{
		char c=get();
		while (c==' '||c=='\n') c=get();
		if (it>0) it--;
		return c!=EOF;
	}
}_buff;
#define geti(x) x=getnum()
#define getii(x,y) geti(x),geti(y)
#define getiii(x,y,z) getii(x,y),geti(z)
#define puti(x) putnum(x),putchar(' ')
#define putii(x,y) puti(x),puti(y)
#define putiii(x,y,z) putii(x,y),puti(z)
#define putsi(x) putnum(x),putchar('\n')
#define putsii(x,y) puti(x),putsi(y)
#define putsiii(x,y,z) putii(x,y),putsi(z)
inline ll getnum()
{
	ll r=0; bool ng=0; char c; c=_buff.get();
	while (c!='-'&&(c<'0'||c>'9')) c=_buff.get();
	if (c=='-') ng=1, c=_buff.get();
	while (c>='0'&&c<='9') r=r*10+c-'0', c=_buff.get();
	return ng?-r:r;
}
template <class T> inline void putnum(T x)
{
	if (x<0) putchar('-'), x=-x;
	register short a[20]={}, sz=0;
	while (x) a[sz++]=x%10, x/=10;
	if(sz==0) putchar('0');
	for (int i=sz-1; i>=0; i--) putchar('0'+a[i]);
}
inline char getreal() {char c=_buff.get(); while (c<=32) c=_buff.get(); return c;}
ll qpow(ll x, ll k) {return k==0? 1: 1ll*qpow(1ll*x*x%mod,k>>1)*(k&1?x:1)%mod;}
const ll MAXP = 10000000019ll;
int A, B;
ll count_below_line(ll p, ll q, ll m, ll bound)
{
	if (p<q) swap(p, q);
	ll ans = 0;
	for (int i=0; i<=m/p&&ans<=bound; i++)
	{
		ans += (m-i*p)/q+1;
	}
	return ans;
}
pair<ll,ll> sum_below_line(ll p, ll q, ll m, ll K)
{
//	cerr<<"sum_below_line:"<<p<<","<<q<<" "<<m<<" "<<K<<"  "<<count_below_line(p, q, m, K)<<endl;
	bool flag = 0;
	if (p<q) swap(p, q), flag = 1;
	ll x = 0, y = 0;
	for (int i=0; i*p<=m-1; i++)
	{
		ll cnt = (m-1-i*p)/q+1;
		K -= cnt;
		x += cnt*i;
		y += 1ll*cnt*(cnt-1)/2;
	}
	assert(K>=0);
	for (int i=0; K>0&&i*p<=m; i++)
	{
		if ((m-i*p)%q==0)
		{
			K--;
			x += i;
			y += (m-i*p)/q;
		}
	}
	if (flag) swap(x, y);
	return MP(x, y);
}
pair<ll,ll> solve_point(int K, ll p, ll q)
{
//	cerr<<"solve_point:"<<K<<" "<<p<<" "<<q<<endl;
	if (p>0&&q>0)
	{
		ll l = 0, r = p*K;
		while (l<=r)
		{
			ll m = l+r>>1;
			ll cnt = count_below_line(p, q, m, K);
			if (cnt<=K) l = m+1;
			else r = m-1;
		}
		return sum_below_line(p, q, r, K);
	}
	else
	{
		if (p==0) return MP(1ll*K*(K-1)/2, 0);
		else return MP(0, 1ll*K*(K-1)/2);
	}
}
bool det_gt_zero(ll ax, ll ay, ll bx, ll by)
{
	double tmp = 1.0*ax*by-1.0*ay*bx;
	if (tmp>1e18) return true;
	if (tmp<-1e18) return false;
	return ax*by-ay*bx>=0;
}
bool solve(int K, ll al, ll ar)
{
	if (al+1==ar)
	{
		pair<ll,ll> pt1 = solve_point(K, al, MAXP-al);
		pair<ll,ll> pt2 = solve_point(K, ar, MAXP-ar);
//		cerr<<pt1.FF<<","<<pt1.SS<<" "<<pt2.FF<<","<<pt2.SS<<" ("<<K<<" "<<al<<","<<ar<<")"<<endl;
		assert(A<=pt1.FF&&A>=pt2.FF);
		assert(B>=pt1.SS&&B<=pt2.SS);
		assert(pt1.FF!=pt2.FF);
		return det_gt_zero(pt1.FF-pt2.FF, pt1.SS-pt2.SS, A-pt2.FF, B-pt2.SS);
	}
	else
	{
		ll am = al+ar>>1;
		pair<ll,ll> pt = solve_point(K, am, MAXP-am);
		if (A>=pt.FF&&B>=pt.SS) return true;
		if (A<pt.FF&&B<pt.SS) return false;
		if (A<pt.FF) return solve(K, am, ar);
		else return solve(K, al, am);
	}
}
int main()
{
	cin>>A>>B;
	int l = 1, r = 10000000;
	while (l<=r)
	{
		ll m = l+r>>1;
		if (solve(m, 0, MAXP)) l = m+1;
		else r = m-1;
	}
	cout<<r-1<<endl;
	return 0;
}


Measured memory_bytes: 256