#include <iostream>

using namespace std;

int main() {

	long long b, c; cin >> b >> c;

	long long ans = 0;

	if (b == 0) {
		if (c == 0)
			ans = 1;
		else
			ans = c;
	}
	else if (0 < b) {
		if (c < 2 * b)
			ans = c + 1;
		else
			ans = 2 * b + 1;
		if (2 < c)
			ans += c - 2;
	}
	else {
		if (c == 0)
			ans = 1;
		else if (c == 1)
			ans = 2;
		else if (c == 2)
			ans = 3;
		else {
			if (c <= 2 * abs(b))
				ans = c;
			else
				ans = 2*abs(b)+1;
			ans += c - 1;
		}
	}
	
	cout << ans << endl;

}
#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;
}
