#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<(n);++i)
using ll=long long;
using namespace std;

int main(){
 ll c,b,ans,ml,mr,pl,pr;
  cin>>b>>c;
  ans=c/2+(c-2)/2+1+(c-1)/2+(c-1)/2+1;
  ml=-b-(c-1)/2;
  mr=-b+(c-1)/2;
  pl=b-c/2;
  pr=b+(c-2)/2;
    
  if(pl<=mr) {//ダブりがある
   ans-= min(abs(mr),abs(pr))+min(abs(pl),abs(ml))+1;
  }
  
  cout<<ans<<endl;
}







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

#define ll long long
#define print(a)          \
    for (auto x : a)      \
        cout << x << " "; \
    cout << endl
#define print_upto(a, n)        \
    for (ll i = 1; i <= n; i++) \
        cout << a[i] << " ";    \
    cout << endl
#define take(a, n)              \
    for (ll i = 1; i <= n; i++) \
        cin >> a[i];

#define watch(x) cout << (#x) << " is " << (x) << "\n"
#define watch2(x, y) cout << (#x) << " is " << (x) << " and " << (#y) << " is " << (y) << "\n"
#define watch3(x, y, z) cout << (#x) << " is " << (x) << " and " << (#y) << " is " << (y) << " and " << (#z) << " is " << (z) << "\n"

#define ff first
#define ss second
#define null NULL
#define all(c) (c).begin(), (c).end()
#define nl "\n"

#define ld long double
#define eb emplace_back
#define pb push_back
#define pf push_front
#define MOD 1000000007
#define inf 1e17
// cout << fixed << setprecision(9) << ans << nl;

typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> pll;
typedef map<ll, ll> mll;

const ll N = 200009;

void solve()
{
    ll b, c;
    cin >> b >> c;

    ll ans = 0;
    if (b < 0)
        ans++;
    b = abs(b);

    if (b == 0)
    {
        ll xr = 0;
        if (c >= 3)
        {
            xr = 1 + (c - 3) / 2;
        }

        ll xl = 0;
        if (c >= 2)
        {
            xl = 1 + (c - 2) / 2;
        }

        cout << 1 + xl + xr << nl;
        return;
    }

    if (c == 0)
    {
        cout << 1 << nl;
        return;
    }

    ll xr;
    if (c < 4)
    {
        xr = 0;
    }
    else
    {
        xr = 1 + (c - 4) / 2;
    }

    ll mxl;
    if (c < 3)
    {
        mxl = 0;
    }
    else
    {
        mxl = 1 + (c - 3) / 2;
    }

    ll xl;
    if (c < 2)
    {
        xl = 0;
    }
    else
    {
        ll limit = min(b * 2, c);
        xl = 1 + (limit - 2) / 2;
    }

    ll mxr;
    if (c < 1)
    {
        mxr = 0;
    }
    else
    {
        ll no = b;
        if (no == 0)
        {
            mxr = 0;
        }
        else
        {
            ll val = 1 + (no - 1) * 2;
            ll limit = min(val, c);
            mxr = 1 + (limit - 1) / 2;
        }
    }

    ans += 1 + xr + mxl + xl + mxr;
    cout << ans << nl;
}

int main()
{

    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    ll t = 1;
    // cin >> t;

    while (t--)
    {
        solve();
    }

    return 0;
}
