#include<bits/stdc++.h>
using ll = int_fast64_t;

int main(){
	ll b, c;
	scanf("%ld %ld", &b, &c);
	ll l1 = b-c/2, r1 = b + std::max(0l, c-2)/2;
	ll l2 = -b-(c-1)/2, r2 = -b + (c-1)/2;
	
	if(l1<=r2 && l2<=r1){
		bool l = (l1<=l2 && l2<=r1);
		bool r = (l1<=r2 && r2<=r1);
		if(l && r) printf("%ld\n", r1-l1+1);
		if(l && !r) printf("%ld\n", r2-l1+1);
		if(!l && r) printf("%ld\n", r1-l2+1);
		if(!l && !r) printf("%ld\n", r2-l2+1);
	}else printf("%ld\n", r1-l1+1 + r2-l2+1);
	return 0;
}
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vvl = vector<vl>;
using pl = pair<ll, ll>;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define rrep1(i,n) for(int i=(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define fore(i_in,a) for (auto& i_in: a)
#define forp(x,y,a) for(auto& [x, y]: a)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pq(T) priority_queue<T, vector<T>, greater<T>>
#define fio() cin.tie(nullptr);ios::sync_with_stdio(false);
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<(int)v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define UNIQUE(v) v.erase(unique(all(v)), v.end());
template<class T> bool chmax(T &a, const T &b) {if (a<b) { a = b; return true; } return 0;}
template<class T> bool chmin(T &a, const T &b) {if (a>b) { a = b; return true; } return 0;}
template<class T> void print(const T &t) { cout << t << "\n"; }

ll a, b, ans;

int main() {
    fio(); cin>>a>>b;
    ll pos_min =  a - b/2;
    ll neg_min = -a - (b-1)/2;
    ll pos_max =  a + (b-2)/2;
    ll neg_max = -a + (b-1)/2;
    if(neg_max < pos_min or pos_max < neg_min) ans = (neg_max - neg_min + 1) + (pos_max - pos_min + 1);
    else ans = max(neg_max, pos_max) - min(pos_min, neg_min) + 1;
    print(ans);
}
