#include <bits/stdc++.h>
 
using namespace std;
 
pair<long, long> exact(const long &B, const long &C) {
  const auto n = C / 2;
  if (C % 2) {
    return {-B - n, -B + n};
  } else {
    if (!C)
      return {B, B};
    return {B - n, B + n - 1};
  }
}
 
int main() {
  long B, C;
  cin >> B >> C;
  const auto [a, b] = exact(B, C);
  const auto [c, d] = exact(B, C - 1);
  cout << (b - a + 1) + (d - c + 1) - max(0l, min(b, d) - max(a, c) + 1)
       << endl;
  return 0;
}
#include <bits/stdc++.h>

using namespace std;

const int N = 1e5 + 7;
int n;

int main()
{
       ios_base::sync_with_stdio(0);
       cin.tie(0);
#ifndef ONLINE_JUDGE
       freopen("in.in", "r", stdin);
#endif
       int x , y; cin >> x >> y;  
       if( x == y) cout << x; else cout << 3 - x - y ; 
       return 0;
}
