#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define REP(i,n) for(ll i=0;i<(n);i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORC(i,a,b,c) for(ll i=(a);i<(b);i+=(c))
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define ff first
#define ss second
#define dd long double
#define all(x) x.begin(),x.end()

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll b,c;
    cin>>b>>c;
    if(b<0){
        ll nl=b,nh=b;
        nl=b-c/2;
        if(c>=2){
            nh=-max(-b-(c-2)/2,1ll);
        }
        ll ans=nh-nl+1;
        if(c>0){
            ll pl=max(-b-(c-1)/2,0ll);
            ll ph=-b+(c-1)/2;
            ans+=ph-pl+1;
        }
        cout<<ans<<endl;
    }
    else{
        ll pl=b,ph=b;
        pl=max(b-c/2,0ll);
        if(c>=2){
            ph=-(-b-(c-2)/2);
        }
        ll ans=ph-pl+1;
        if(c>0){
            if(b){
                c--;
            }
            ll nl=-b-(c)/2;
            ll nh=-max(1ll,b-(c)/2);
            ans+=nh-nl+1;
        }
        cout<<ans<<endl;
    }
}

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


int main() {
    ll B, C;
    cin >> B >> C;

    ll ans;

    ll k = C / 2;
    int r = C % 2;

    if (C == 0) {
        ans = 1;
    } else if (B == 0) {
        ans = C;
    } else if (C == 1) {
        ans = 2;
    } else if (B > 0) {
        if (C <= 2 * B) {
            ans = 2 * C - 1;
        } else {
            ans = 2 * B + C - 1;
        }
    } else {
        if (C <= -2 * B - 2) {
            ans = 2 * C - 1;
        } else {
            ans = -2 * B + C;
        }
    }

    cout << ans << endl;
}