#include <iostream>
//#include <vector>
//#include <string>
//#include <algorithm>
//#include <math.h>
//#include <queue>
//#include <stack>
//#include <iomanip>

// sometimes used
//#include <set>
//#include <map>
//#include <numeric>
//#include <list>
//#include <deque>
//#include <unordered_map>

typedef long long LL;
//typedef long double LD;
using namespace std;
 
//#define MOD 1000000007
//#define MOD 998244353
//#define MAX 200100
//#define NIL -1
//#define INF 1000000000000000000
//const LL SEG_VAL = 1 << 19;

pair<LL, LL> exact(const LL &B, const LL &C){
    const auto n = C/2;
    if(C%2){
        return {-B-n, -B+n};
    }else{
        if(!C){
            return {B, B};
        }
        return {B-n, B+n-1};
    }
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(0);

    LL B;
    LL C;
    cin >> B >> C;
    pair<LL, LL> ab = exact(B, C);
    pair<LL, LL> cd = exact(B, C-1);
    cout << (ab.second-ab.first+1)+(cd.second-cd.first+1)-max((LL)0, min(ab.second,cd.second)-max(ab.first,cd.first)+1) << endl;
    
    return 0;
}

#include <bits/stdc++.h>

using namespace std;

#define  ll long long
#define ld long double
#define f first
#define s second

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

    ll b , c , l , r;
    vector< pair<ll,ll> > v;

    cin >> b >> c;

    //awel segment, min positive number a2dar ageboh
    r = b , l = b-c/2;
    v.push_back({l,r});

    //tany segment, min negative a2dar ageboh
    r = -b , l = -(b - (c-1)/2);
    v.push_back({l,r});

    //talet seg, max neg
    r = -b , l = -b - (c-1)/2;
    v.push_back({l,r});

    //rabe3 seg, max positive a2dar ageboh
    l = b , r = b + (c-2)/2;
    v.push_back({l,r});

    set<ll> st;
    for(int i=0; i<v.size(); i++)
    {
        if (v[i].f > v[i].s) swap(v[i].f , v[i].s);
    }
    sort(v.begin() , v.end());

    ll ans = 0;
    l = v[0].f , r = v[0].s;
    for(int i=1; i<v.size(); i++)
    {
        if (v[i].f <= r) r = max(r , v[i].s);
        else
        {
            ans += (r-l+1);
            l = v[i].f , r = v[i].s;
        }
    }

    ans += (r-l+1);
    cout << ans << '\n';

    return 0;
}
