#include<bits/stdc++.h>
#define LL long long
#define SZ(x) (int)x.size()-1
#define F(i,a,b) for (int i=a;i<=b;++i)
#define DF(i,a,b) for (int i=a;i>=b;--i)
#define pb push_back
#define ms(a,b) memset(a,b,sizeof a)
using namespace std;
LL read(){
    char ch=getchar(); LL w=1,c=0;
    for (;!isdigit(ch);ch=getchar()) if (ch=='-') w=-1;
    for (;isdigit(ch);ch=getchar()) c=(c<<3)+(c<<1)+(ch^48);
    return w*c;
}
struct Li{
	LL l,r;
};
bool cmp(Li A,Li B){
	return A.l<B.l;
}
LL B,C;
Li a[10]; 
int main(){
	cin>>B>>C;
	if (C==1){
		cout<<(B ? 2 : 1)<<"\n";
		return 0;
	}
	a[0]=(Li){B-C/2,B},a[2]=(Li){-B-(C-1)/2,-B};
	a[1]=(Li){-B,-(B-(C-1)/2)},a[3]=(Li){B,B+(C-2)/2};
	sort(a,a+4,cmp);
	LL ans=0,pos=a[0].r,lp=a[0].l;
	F(i,1,3){
		if (a[i].l>pos){
			ans=pos-lp+1;
			pos=a[i].r;
			lp=a[i].l;
		}
		else pos=max(pos,a[i].r);
	}
	ans+=pos-lp+1;
	cout<<ans<<'\n';
    return 0;
}


#include<bits/stdc++.h>
using namespace std;

int main(){
  long long int b, c; cin >> b >> c;
  long long int ansin = 0, ansout = 0;
  long long int C = c, B = b;
  
  long long int p1 = 0, p2 = 1;
  p1 = 2*abs(b)+1;
  if(b<0){
  	if(c>0){
    	C--;
    	p2++;
    }
    p2 += C-1; 
  }
  else{
    if(c>0) p2++;
    p2 += C-1;
  }
  ansin = min(p1, p2);
  
  if(b>0){
  	b *= -1;
  	c--;
  }
  ansout = c-1;
  if(c<=0) ansout = 0;
  
  cout << ansin + ansout << endl;
}