#include<bits/stdc++.h>
using namespace std;
long long n,K,T[3000000];
long long f(long long a){
  if(a<2)return 0;
  else if(a<=n+1)return a-1;
  else if(a<=n+n)return n+n+1-a;
  else return 0;
}
long long S(long long k){
	if(k<0) return 0;
	else if(k<n) return (k+2)*(k+1)/2;
	else if(k<2*n-2)return (9*n-3*n*n+6*k*n-6*k-2*k*k-4)/2;
	else if (k<3*n-2) return (3*n-k-1)*(3*n-k-2)/2;
	else return 0;
}
int main(){
	cin >> n >> K;
  	T[0]=1;
  	for(long long i=1;i<3*n-2;i++){
      T[i]=T[i-1]+S(i);
    }
  	long long lb = -1; 
    long long ub = 3*n-2;
  	while(ub - lb>1){
    	long long mid = (lb+ub)/2;
    	if(T[mid]>=K) ub = mid;
    	else lb = mid;
  	}
  	ub+=3;
  	K-=T[lb];
  	for(long long a=1;a<=ub-2;a++){
      K-=f(ub-a);
      if(K<=0){
        if(ub-a>=n+1){
          cout << a << " " << n+K << " " << ub-a-n-K << endl;
        }else{
          cout << a << " " << ub-a-1+K << " " << 1-K << endl;
        }
        break;
      } 
	}
  	return 0;
}
// Problem: B - -- - B
// Contest: AtCoder - AtCoder Regular Contest 112
// URL: https://atcoder.jp/contests/arc112/tasks/arc112_b
// Memory Limit: 1024 MB
// Time Limit: 2000 ms
// 
// Powered by CP Editor (https://cpeditor.org)

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int,int>;
#define pb push_back
#define mp make_pair
const double PI = 4*atan(1);
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3f;
const int MOD = 1e9+7;
const int MAX_N = 2e6+10;

ll B, C;

void solve()
{
	if(!C) cout<<1<<'\n';
	else if(!B) cout << C << '\n';
	else{
		// *-1 ----- *-1
		ll L1 = B-C/2, R1 = B+(C>=2?(C-2)/2:0);
		ll L2 = -B-(C-1)/2,R2=-B+(C-1)/2;
		if(R1<L2 || R2<L1){
			cout<<R1+R2-L1-L2+2<<'\n';
		}else{
			cout<<max(R1,R2)-min(L1,L2)+1<<'\n';
		}
	}
}


int main()
{
	cin >> B >> C;
	solve();
	return 0;
}