#include <bits/stdc++.h>

using namespace std;

long long count_inward(long long B, long long C){
  long long ans = 1;

  if(C){
    if(B > 0){
      ans++;
    }

    if(B < 0){
      B *= -1;
      C--; ans++;
    }
  }

  if(B == 0 or C == 0) return ans;

  long long k = min(B-1, (C-1)/2);
  ans += 2*k; C -= 2*k; B -= k;
  if(C >= 2) ans++;

  return ans;
}

long long count_outward(long long B, long long C){
  long long ans = 0;

  if(B > 0 and C){
    B *= -1; C--;
  }

  if(C == 0) return ans;

  long long k = (C-1)/2;
  ans += 2*k; C -= 2*k; B -= k;
  if(C >= 2) ans++;

  return ans;
}

int main(){
  long long B, C;
  while(scanf("%lld%lld", &B, &C) > 0){
    printf("%lld\n", count_inward(B, C) + count_outward(B, C));
  }
}

#include <bits/stdc++.h>

using namespace std;
using int64 = long long;

constexpr int DEBUG = 0;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);

  int64 b, c;
  cin >> b >> c;
  int64 l1 = b - c / 2;
  int64 u1 = b + max(c - 2, 0LL) / 2;
  int64 l2 = -b - max(c - 1, 0LL) / 2;
  int64 u2 = -b + max(c - 1, 0LL) / 2;

  int64 c1 = u1 - l1 + 1;
  int64 c2 = u2 - l2 + 1;
  int64 ans = c1 + c2;
  int64 l3 = max(l1, l2);
  int64 u3 = min(u1, u2);
  if (l3 <= u3) {
    ans -= u3 - l3 + 1;
  }
  cout << ans << endl;
}