#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
#define int ll
#define _FastIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define pii pair<int , int>
#define pb emplace_back
const int MAXX = 1e5 + 5;

int b , c ;

signed main()
{
    _FastIO;
    cin >> b >> c;
    long long ans = 0;
    if(b && c == 1){
        cout << "2" << endl;
        return 0;
    }
    if(!b){
        cout << c << endl;
        return 0;
    }
    if(b > 0){
    int cnt = 0;
    b *= (-1);
    c--;
    cnt = 1;
    while(cnt){
    int x = c / 2;
    int y = b - x;
    ans += 2 * x + 2;
    if(b >= 0 && y <= 0){
        ans--;
    }
    if(c % 2 == 0 && y){
        ans--;
    }
    cnt = 0;
}
    b *= (-1);
    c++;
    while(!cnt){
        int x = c / 2;
    int y = b - x;
    bool f = true;
    if(y <= 0){
        y = 0;
         f = false;
    }
    x = b - y - 1;
    ans += (2 * x + 2);
    if(b >= 0 && y <= 0){
        ans--;
    }
    if(c % 2 == 0 && y && f){
        ans--;
    }
    cnt = 1;
    }
    cout << ans << endl;
    }
    if(b <= 0){

    int cnt = 0;
    b *= (-1);
    c--;
    cnt = 1;
    while(cnt){
    int x = c / 2;
    int y = b - x;

    bool f = true;
    if(y <= 0){
        y = 0;
         f = false;
    }
    x = b - y - 1;
    ans += 2 * x + 2;
    if(b >= 0 && y <= 0){
        ans--;
    }
    if(c % 2 == 0 && y && f ){
        ans--;
    }
    cnt = 0;
}
    b *= (-1);
    c++;
    while(!cnt){
        int x = c / 2;
    int y = b - x;
    ans += (2 * x + 2);
    if(b >= 0 && y <= 0){
        ans--;
    }
    if(c % 2 == 0 && y){
        ans--;
    }
    cnt = 1;
    }
    cout << ans << endl;
    }
    return 0;
}

#include <bits/stdc++.h>
using namespace std;

const int N = 200005;

typedef pair<long long, long long> pll;

long long b, c;

int solve() {
  scanf("%lld %lld", &b, &c);

  long long ans = 0;
  pll range1 = {b - c/2, b + max(0LL, c - 2) / 2};
  pll range2 = {-b - (c - 1) / 2, -b + (c - 1) / 2};

  // cerr << range1.first << " " << range1.second << endl;
  // cerr << range2.first << " " << range2.second << endl;

  if (max(range1.first, range2.first) <= min(range1.second, range2.second)) ans = max(range1.second, range2.second) - min(range1.first, range2.first) + 1;
  else ans = range1.second - range1.first + 1 + range2.second - range2.first + 1;

  printf("%lld\n", ans);

  return 0;
}

int main() {
  int t = 1;
  // scanf("%d", &t);
  for (int tc = 0; tc < t; ++tc) {
    solve();
  }
  return 0;
}
