#include <bits/stdc++.h>
#ifndef ONLINE_JUDGE
#define debug(x) cout << #x << ": " << (x) << endl
#else
#define debug(x)
#endif
using namespace std;
typedef long long ll;
typedef vector<int> vi;
const int maxn=1e6+7,inf=0x3f3f3f3f,mod=1e9+7;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll b,c;
    cin>>b>>c;
    ll pmx,pmi,nmx,nmi;
    if(b<0)
    {
        nmi=b-c/2;
        pmi=(-b)-(c-1)/2;
        pmx=max(-b+c/4+(c%4>=3),-nmi-((c%2)?0:1));
        nmx=max(b+(c-1)/4+((c-1)%4>=3),-pmi-(((c-1)%2)?0:1));
    }
    else if(b>0)
    {
        nmi=-b-(c-1)/2;
        pmi=b-(c)/2;
        pmx=max(b+(c-1)/4+((c-1)%4>=3),-nmi-(((c-1)%2)?0:1));
        nmx=max(-b+c/4+(c%4>=3),-pmi-((c%2)?0:1));
    }
    else if(b==0)
    {
        nmi=-b-(c)/2;
        pmi=0;
        pmx=-nmi-(((c)%2)?0:1);
        nmx=0;
    }
    cout<<pmx-pmi+1+nmx-nmi+1-max(0ll,nmx-pmi+1);
    return 0;
}

/*#include<bits/stdc++.h>
using namespace std;
long long b,c,sub,ans;
int main()
{
	scanf("%lld%lld",&b,&c);
	sub=c/2;
	if(c&1)
	{
		ans=(sub+1)*2ll;
		if(b-sub<=0&&0<=b) ans--;
	}
	else
	{
		ans=sub*2ll+1;
		if(b-(sub-1)<=0&&0<=b) ans--;
	}
	if(b>0&&b-sub<0) ans-=min(b,sub-b);//max(abs(b),abs(b-sub))-min(abs(b),abs(b-sub));
	printf("%lld\n",ans);
	return 0;
}*/
#include<bits/stdc++.h>
using namespace std;
long long b,c,sub,ans;
long long l[5],r[5];
int main()
{
	scanf("%lld%lld",&b,&c);
	sub=c/2;
	l[1]=b-sub;r[1]=b;
	if(c&1) l[2]=-b,r[2]=sub-b;
	else l[2]=-b,r[2]=sub-b-1;
	if(c&1) l[3]=-b-sub,r[3]=-b;
	else l[3]=-b-sub+1,r[3]=-b;
	l[4]=b,r[4]=b+sub-1;
	//for(int i=1;i<=4;i++) printf("%lld %lld\n",l[i],r[i]);
	for(int i=3;i>=1;i--)
		for(int j=i+1;j<=4;j++)
		{
			if(l[i]<=l[j]&&l[j]<=r[i]&&r[i]<=r[j])
				r[i]=r[j],l[j]=0,r[j]=-1;
			else if(l[j]<=l[i]&&l[i]<=r[j]&&r[j]<=r[i])
				l[i]=l[j],l[j]=0,r[j]=-1;
			else if(l[i]<=l[j]&&l[j]<=r[j]&&r[j]<=r[i])
				l[j]=0,r[j]=-1;
			else if(l[j]<=l[i]&&l[i]<=r[i]&&r[i]<=r[j])
				l[i]=l[j],r[i]=r[j],l[j]=0,r[j]=-1;
		}
	//for(int i=1;i<=4;i++) printf("%lld %lld\n",l[i],r[i]);
	for(int i=1;i<=4;i++) ans+=r[i]-l[i]+1;
	printf("%lld\n",ans);
	return 0;
}