#include using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); long long gx, gy; cin >> gx >> gy; // ルークの手数 int rook; if (gx == 0 && gy == 0) { rook = 0; } else if (gx == 0 || gy == 0) { rook = 1; } else { rook = 2; } // ビショップの手数 int bishop; if (gx == 0 && gy == 0) { bishop = 0; } else if (((gx + gy) & 1) != 0) { bishop = INT_MAX; // 到達不可 } else if (llabs(gx) == llabs(gy)) { bishop = 1; } else { bishop = 2; } // 答え int ans = min(rook, bishop); cout << ans << "\n"; return 0; }