#include #define ll long long using namespace std; const int inf = 1073741823; int main() { ll gx, gy; cin >> gx >> gy; int rook, bishop; if (gx == 0 && gy == 0) { rook = 0; } else if (gx == 0 || gy == 0) { rook = 1; } else { rook = 2; } if (gx == 0 && gy == 0) { bishop = 0; } else if (gx + gy == 0 || gx - gy == 0) { bishop = 1; } else if ((gx + gy) % 2 == 0) { bishop = 2; } else { bishop = inf; } cout << min(rook, bishop) << endl; }