#include #include using namespace std; int main() { long long Gx, Gy; cin >> Gx >> Gy; if (Gx == 0 && Gy == 0) { cout << 0 << endl; return 0; } // ルークの場合の手数 int rook_moves; if (Gx == 0 || Gy == 0) { rook_moves = 1; } else { rook_moves = 2; } int bishop_moves; if (abs(Gx) == abs(Gy)) { bishop_moves = 1; } else if ((Gx + Gy) % 2 == 0) { bishop_moves = 2; } else { bishop_moves = -1; } if (bishop_moves == -1) { cout << rook_moves << endl; } else { cout << min(rook_moves, bishop_moves) << endl; } return 0; }