#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
#include <bitset>
#include <cstddef>
#include <type_traits>
#include <vector>
 
using namespace std;
using lint = long long int;
long long int INF = 1001001001001001LL;
int inf = 1000000007;
long long int MOD = 1000000007LL;
double PI = 3.1415926535897932;
 
template<typename T1,typename T2>inline void chmin(T1 &a,const T2 &b){if(a>b) a=b;}
template<typename T1,typename T2>inline void chmax(T1 &a,const T2 &b){if(a<b) a=b;}
 
#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()
#define rep(i, n) for(int i=0;i<(int)(n);i++)

int main() {
  
  lint b, c; cin >> b >> c;
  map<lint, lint> imos;

  // -1 しまくる
  {
    lint l = min(b - c / 2, b);
    lint r = max(b - c / 2, b);
    imos[l]++;
    imos[r + 1]--;

    // cerr << l << " " << r << endl;
  }
  // 最後に -1 倍する
  {
    lint l = min(-(b - (c - 1) / 2), -b);
    lint r = max(-(b - (c - 1) / 2), -b);
    imos[l]++;
    imos[r + 1]--;
    // cerr << l << " " << r << endl;
  }
  // -1 倍して、-1 しまくる
  {
    lint l = min(-b - (c - 1) / 2, -b);
    lint r = max(-b - (c - 1) / 2, -b);
    imos[l]++;
    imos[r + 1]--;
    // cerr << l << " " << r << endl;
  }
  // 最初と最後に -1 倍する
  {
    lint l = min(b + (c - 2) / 2, b);
    lint r = max(b + (c - 2) / 2, b);
    imos[l]++;
    imos[r + 1]--;
  }

  lint pre = -1e18 * 3;
  lint num = 0;
  lint ans = 0;
  for (auto e : imos) {
    lint cur = e.first;
    // cerr << "cur = " << cur << " num = " << num << endl;
    if (num > 0) {
      // cerr << "add: " << cur - pre << endl;
      ans += (cur - pre);
    }
    pre = cur;
    num += e.second;
  }

  cout << ans << endl;
  return 0;
}

#include <set>
#include <unordered_set>
#include <iostream>
#include <stack>
#include <string>
#include <sstream>
#include <vector>
#include <map>
#include <cmath>
#include <numeric>
#include <algorithm>
#include <queue>
#include <bitset>

#define INFL 100100100100100100
#define INF 1100100100
using namespace std;


int main() {
	long long b;
	cin >> b;
	long long c;
	cin >> c;
	long long br, bl, brr, bll;
	br = b + (c-2)/2;
	bl = b - c/2;
	brr = -b + (c-1)/2;
	bll = -b - (c-1)/2;
	if (br < brr || bl < bll) {
		swap(br, brr);
		swap(bl, bll);
	}
	cout << br - bl + 1 + brr - bll + 1 - (bl <= brr ? brr - bl + 1: 0) << endl;
	return 0;
}