#include <iostream>

using namespace std;
typedef long long ll;


int main (void)
{
	ll b , c;
	cin >> b >> c;
	ll la , ra , lb , rb;

	ll ans = 0;

	if (b > 0)
	{
		lb = b - c / 2;
		rb = b + (c - 2) / 2;
		la = -b - (c - 1) / 2;
		ra = -(b - (c - 1) / 2);
		if (lb > ra)
			ans = rb - lb + ra - la + 2;
		else
			ans = rb - la + 1;
	}
	else
	{
		lb = b - c / 2;
		rb = b + (c - 2) / 2;
		la = -b - (c - 1) / 2;
		ra = -(b - (c - 1) / 2);
		if (la > rb)
			ans = ra - la + rb - lb + 2;
		else
			ans = ra - lb + 1;
	}
	cout << ans << endl;
	return 0;
}
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)
typedef long long ll;

int main(){
  ll b,c;cin>>b>>c;
  ll ans=0;
  bool f=true;
  if(b<0) f=false;
  b=abs(b);

  if(b==0){
    ans=c;
  }else if(c>2*b){
    if(f) ans=2*b+c-1;
    else ans=2*b+c;
  }else if(c>=3){
    ans=2*c-1;
  }else{
    ans=c+1;
  }

  cout<<ans<<endl;
}