// Artur Kraska, II UWr

#include <bits/stdc++.h>

#define forr(i, n)                  for(int i=0; i<n; i++)
#define FOREACH(iter, coll)         for(auto iter = coll.begin(); iter != coll.end(); ++iter)
#define FOREACHR(iter, coll)        for(auto iter = coll.rbegin(); iter != coll.rend(); ++iter)
#define lbound(P,R,PRED)            ({typeof(P) X=P,RRR=(R), PPP = P; while(PPP<RRR) {X = (PPP+(RRR-PPP)/2); if(PRED) RRR = X; else PPP = X+1;} PPP;})
#define testy()                     int _tests; scanf("%d", &_tests); FOR(_test, 1, _tests)
#define CLEAR(tab)                  memset(tab, 0, sizeof(tab))
#define CONTAIN(el, coll)           (coll.find(el) != coll.end())
#define FOR(i, a, b)                for(int i=a; i<=b; i++)
#define FORD(i, a, b)               for(int i=a; i>=b; i--)
#define MP                          make_pair
#define PB                          push_back
#define ff                          first
#define ss                          second
#define deb(X)                      X;

#define M 1000000007
#define INF 1000000007LL

using namespace std;

int n, m, a;
long long b, c;

int main()
{
    scanf("%lld %lld", &b, &c);
    long long l1 = -b-(c-1)/2, r1 = -b+(c-1)/2, l2 = b-c/2, r2 = b+(c-2)/2;
    if(b < 0)
    {
        swap(l1, l2);
        swap(r1, r2);
    }
    {
        if(l2 <= r1)
            printf("%lld\n", max(r1, r2)-min(l1, l2)+1);
        else
            printf("%lld\n", r1-l1+1 + r2-l2+1);
    }

    return 0;
}

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

int main()
{
	ll B,C;
	cin >> B >> C;
	/*
	ll L = B - (C-1)/2;
	ll R = B;
	ll ans = 0;
	if ((L < 0 && R > 0) || (L < 0 && R < 0))
	{
		ans = 2 * max(abs(L-R));
	}
	else
	{
		ans = 2 * max(abs(L),abs(R)) + 1;
	}
	if (C % 2 == 0)
	{
		
	}
	*/
	vector<P> v;
	v.push_back(P(B-(C-1)/2,1));
	v.push_back(P(B+1,-1));
	v.push_back(P(-1*(B-(C-1)/2)+1,-1));
	v.push_back(P(-1*B,1));

	v.push_back(P(-1*B-(C/2-1),1));
	v.push_back(P(-1*B+1,-1));
	v.push_back(P(-1*(-1*B-(C/2-1))+1,-1));
	v.push_back(P(B,1));

	v.push_back(P(B-C/2,1));
	v.push_back(P(B-C/2+1,-1));

	v.push_back(P(-1*B-(C-1)/2,1));
	v.push_back(P(-1*B-(C-1)/2+1,-1));
	
	sort(v.begin(), v.end());

	ll ans = 0;
	ll tmp = v[0].first;
	int t = 1;
	for (int i = 1; i < v.size(); ++i)
	{
		if (t > 0)
		{
			ans += v[i].first - tmp;
		}
		tmp = v[i].first;
		t += v[i].second;
	}
	cout << ans << endl;
	return 0;
}