//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using ld = long double;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;
template<class T> using PQ = priority_queue<T>;
template<class T> using PQG = priority_queue<T, vector<T>, greater<T> >;
const int INF = 0xccccccc;
const ll LINF = 0xcccccccccccccccLL;
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) {return a < b && (a = b, true);}
template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) {return a > b && (a = b, true);}
template<typename T1, typename T2>
istream &operator>>(istream &is, pair<T1, T2> &p) { return is >> p.first >> p.second;}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) { return os << p.first << ' ' << p.second;}



//head



int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll b, c;
  cin >> b >> c;
  ll ul = b-c/2, ur = max(b, b+c/2-1);
  ll dl = min(-b, -b-(c-1)/2), dr = max(-b, -b+(c-1)/2);
  ll l = min(ul, dl), r = max(ur, dr);
  ll ans = r-l+1;
  if(ul > dr) ans -= ul-dr-1;
  if(dl > ur) ans -= dl-ur-1;
  cout << ans << endl;
}
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < n; i++)
#define REPR(i, n) for(ll i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(ll i = m; i <= n; i++)
#define FORR(i, m, n) for(ll i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n)
#define MAX 100000
#define inf 1000000007
using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;
using graph = vector<vector<int>>;
using Grid = vector<vector<bool>>;

int main() {
    ll b, c, ans;
    ans = 0;
    cin >> b >> c;

    if(b == 0){
        if(c < 2){
            cout << 1 << endl;
            return 0;
        }else{
            ans = c;
        }
    }else if(b > 0){ // b > 0
        if(c < 3){
            cout << c+1 << endl;
            return 0;
        }else{
            if(2 * b - c > 0){
                ans = 3 + (c-2)*2;
            }else{
                ans = (c-2) + (2 * b + 1);
            }
        }
    }else{ // b < 0
        if(c < 3){
            cout << c+1 << endl;
            return 0;
        }else{
            if(-2 * (-b) + 1 - c > 0){
                ans = 3 + (c-2)*2;
            }else{
                ans = (c-1) + (2 * (-b) + 1);
            }
        }
    }
	cout << ans << endl;
	return 0;
}