#include<iostream>
#include<cstdio>
#include<algorithm>
namespace do_while_true {
	#define ld double
	#define ll long long
	#define re register
	#define pb push_back
	#define fir first
	#define sec second
	#define pp std::pair
	#define mp std::make_pair
	const ll mod = 998244353;
	template <typename T>
	inline T Max(T x, T y) { return x > y ? x : y; }
	template <typename T>
	inline T Min(T x, T y) { return x < y ? x : y; }
	template <typename T>
	inline T Abs(T x) {	return x < 0 ? -x : x; }
	template <typename T>
	inline T& read(T& r) {
		r = 0; bool w = 0; char ch = getchar();
		while(ch < '0' || ch > '9') w = ch == '-' ? 1 : 0, ch = getchar();
		while(ch >= '0' && ch <= '9') r = r * 10 + (ch ^ 48), ch = getchar();
		return r = w ? -r : r;
	}
	template <typename T>
	inline T qpow(T x, T y) {
		re T sumq = 1; x %= mod;
		while(y) {
			if(y&1) sumq = sumq * x % mod;
			x = x * x % mod;
			y >>= 1;
		}
		return sumq;
	}
	char outch[110];
	int outct;
	template <typename T>
	inline void print(T x) {
		do {
			outch[++outct] = x % 10 + '0';
			x /= 10;
		} while(x);
		while(outct >= 1) putchar(outch[outct--]);
	}
}
using namespace do_while_true;

ll B, C;

void solve() {
	read(B); read(C);
	if(C == 1) {
		printf("%d\n", B == 0 ? 1 : 2);
		return ;
	}
	ll down1 = B - (C / 2), up1 = B + ((C - 2) / 2);
	B = -B; C--;
	ll down2, up2;
	if(C == 1) {
		printf("%lld\n", up1 - down1 + 1 + (!(down1 <= B && B <= up1)));
		return ;
	}
	down2 = B - (C / 2), up2 = B + (C / 2);
	if(Max(down1, down2) <= Min(up1, up2)) {
		printf("%lld\n", Max(up1, up2) - Min(down1, down2) + 1);
	}
	else {
		printf("%lld\n", up1 - down1 + 1 + up2 - down2 + 1);
	}
}

signed main() {
	#ifndef ONLINE_JUDGE
//	freopen("in.txt", "r", stdin);
	#endif
	int T = 1;
//	read(T);
	while(T--) solve();
	fclose(stdin);
	return 0;
}

#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;
}
