#include #include using namespace std; int main() { long long Gx, Gy; cin >> Gx >> Gy; int rook_moves; if (Gx == 0 && Gy == 0) { rook_moves = 0; } else if (Gx == 0 || Gy == 0) { rook_moves = 1; } else { rook_moves = 2; } int bishop_moves; if (Gx == 0 && Gy == 0) { bishop_moves = 0; } else if ((Gx + Gy) % 2 != 0) { bishop_moves = INT_MAX; // 移動不可能 } else if (Gx == Gy || Gx == -Gy) { bishop_moves = 1; } else { bishop_moves = 2; } int min_moves = min(rook_moves, bishop_moves); cout << min_moves << endl; return 0; }