#include <bits/stdc++.h>
#define ff first
#define ss second
#define endl '\n'
using namespace std;
const long long INF = (long long) 1e18;
const int mod = (int) 1e9+7;
const int MAXN = (int) 3e5+5;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
ll n;

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

    #ifdef Local
        freopen("C:/Users/Admin/Desktop/Yazilim/C/IO/int.txt","r",stdin);
        freopen("C:/Users/Admin/Desktop/Yazilim/C/IO/out.txt","w",stdout);
    #endif

    ll b, c;

    cin>>b>>c;

    pll ara[4];

    if(b > 0){
        ara[0] = {-b - (c - 1) / 2,  -b};
        ara[1] = {b,  max(b, - (- b - c / 2)  - 1)};
        ara[2] = {b - c / 2, b};
        ara[3] = {-b, -(b - (c - 1) / 2)};
    }else if(b < 0){
        ara[0] = {b - c / 2, b};
        ara[1] = {-b, -b + (c - 1) / 2};
        ara[2] = {-b - (c - 1) / 2, -b};
        ara[3] = {b, - (-b - c / 2 + 1)};
    }else if(b == 0){
        ara[0] = {-c / 2, 0};
        ara[1] = {0, (c - 1) / 2};
        ara[2] = {0, 0};
        ara[3] = {0, 0};
    }
    sort(ara, ara + 4);

    ll cur = -3e18;

    ll ans = 0;

    for(pll u: ara){
        //cerr<<u.ff<<" "<<u.ss<<endl;
        if(u.ff > cur){
            ans += u.ss - u.ff + 1;
            cur = u.ss;
        }else{
            ans += max(0LL, u.ss - cur);
            cur = max(cur, u.ss);
        }
    }

    cout<<ans<<endl;



    #ifdef Local
        cout<<endl<<fixed<<setprecision(2)<<1000.0 * clock() / CLOCKS_PER_SEC<< " milliseconds ";
    #endif
}
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++);
using i64=int64_t ;

int main() {
    i64 b, c;
    cin >> b >> c;
    i64 ans;
    if(c==0) {
        ans=1;
    }
    if(c!=0 && b==0) {
        ans=c;
    }
    if(0<c && c<=2 && b!=0) {
        ans=c+1;
    }
    if(3<=c && b!=0 && 2*abs(b)>=c) {
        ans=3+(c-2)*2;
    }
    if(3<=c && b!=0 && 2*abs(b)<c) {
        if(b<0) {
            ans=c-2*b;
        } else if(b>0) {
            ans=c+2*b-1;
        }
    }
    cout << ans << endl;
}