#include <bits/stdc++.h>
//#include <atcoder/all>
//using namespace atcoder;
using namespace std;
using vi = vector<int>;
using vb = vector<bool>;
using vl = vector<long>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvb = vector<vector<bool>>;
using vvc = vector<vector<char>>;
using vvl = vector<vector<long>>;
using pii = pair<int, int>;
using pil = pair<int, long>;
using pll = pair<long, long>;
using ll = long long;
#define fix20 cout << fixed << setprecision(20)
#define YES cout << "Yes" << endl
#define NO cout << "No" << endl
#define rep(i,n) for(long i=0; i<(long)(n);i++)
#define REP(i,s,t) for(long i=s; i<t; i++)
#define RNG(i,s,t,u) for(long i=s; i<t; i+=u)
#define MOD 1000000007
#define all(vec) vec.begin(), vec.end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main(){
  ll b,c;
  cin >> b >> c;
  ll h = c/2;
  ll odd = c % 2;
  ll sum = 0;
  if(b > 0){
    if(b - h > 0){
      //sum += (h+1)*2 - (1 - odd);
      //ll r = max((ll)0,c-1);
      //sum += r-1;
      sum += c+1;
      sum += max((ll)0, c-2);
    }else{
      // sum += 2*b + 1;
      // ll r = max((ll)0,c-1);
      // sum += r-1;
      sum += b*2 + 1;
      sum += max((ll)0, c-2);
    }
  }else if(b < 0){
    ll rb = -1*b;
    if(rb*2 + 1 > c){
      sum += c;
      sum += max((ll)1, c);
    }else{
      sum += 2*rb;
      sum += max((ll)1, c);
    }
  }else{
    sum += max((ll)1, c);
  }
  cout << sum << endl;
}
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
static long long INF = (1LL<<62);

// b>0が前提
LL g(LL b, LL c){
	if(c == 1) return 2;
	if(c == 2) return 3;
	LL l = -b - ((c-1)/2);
	LL r = -l;
	if((c-1)%2 == 0){ r--; }
	LL e = b - (c/2);
	LL ret;
	if(e > 0){
		if(c%2 == 0){ e++; }
		// l～rのうち、-e～eを除く
		ret = r - l + 1 - (2*(e-1) + 1);
		if(c%2 == 0){ ret++; } //eの分をカウントする
	}
	else{
		// l～r全てが対象
		ret = r - l + 1;
	}
	return ret;
}

// b<0が前提
LL h(LL b, LL c){
	if(b != 0 && c == 1){ return 2; }
	if(b == 0 && c == 1){ return 1; }
	LL l = b - (c/2);
	LL r = -l;
	if(c%2 == 0){ r--; }
	LL e = -b - ((c-1)/2);
	LL ret;
	if(e > 0){
		if((c-1)%2 == 0){ e++; }
		// l～rのうち、-e～eを除く
		ret = r - l + 1 - (2*(e-1) + 1);
		if((c-1)%2 == 0){ ret++; } //eの分をカウントする
	}
	else{
		// l～r全てが対象
		ret = r - l + 1;
	}
	return ret;
}

LL f(LL b, LL c){
	if(c == 0){ return 1; }
	if(b < 0){ return h(b, c); }
	else if(b == 0){
		if(c == 1) return 1;
		if(c == 2) return 2;
		LL ret = h(-1, c-2);
		if((1-(c-2))/2 >= 0) ret++; //hの結果が0を含まない場合、0を加算しておく
		return ret;
	}
	else{
		return g(b, c);
	}
}

int main(int argc, char* argv[]){
	cin.tie(0); ios::sync_with_stdio(false);
	LL B, C; cin >> B >> C;
	LL ans = f(B, C);
	printf("%lld\n", ans);
	return 0;
}