#include #include using namespace std; int main() { long long Gx, Gy; cin >> Gx >> Gy; // Calculate minimum moves for Rook int rook_moves; if (Gx == 0 && Gy == 0) { rook_moves = 0; // Already at the goal } else if (Gx == 0 || Gy == 0) { rook_moves = 1; // Can reach in one move (horizontally or vertically) } else { rook_moves = 2; // Need two moves: one horizontal and one vertical } // Calculate minimum moves for Bishop int bishop_moves; if (Gx == 0 && Gy == 0) { bishop_moves = 0; // Already at the goal } else if (abs(Gx) == abs(Gy)) { bishop_moves = 1; // Can reach in one move (on a diagonal) } else { // For any point not on the main diagonals, we need 2 moves // With real numbers k, a bishop can reach any point in 2 moves bishop_moves = 2; } // Choose the piece that requires fewer moves int result = min(rook_moves, bishop_moves); cout << result << endl; return 0; }