#include using namespace std; using ll = long long; int main(){ ios::sync_with_stdio(false); cin.tie(0); int r = 200, x, y; vector> dp(2 * r + 1, vector(2 * r + 1, 1 << 30)); queue> nxt; cin >> x >> y; dp[x + r][y + r] = 0; nxt.emplace(x + r, y + r); while(!nxt.empty()){ tie(x, y) = nxt.front(); nxt.pop(); x -= r, y -= r; if(dp[x + r][y + r] + 1 < dp[y + r][x + r]){ dp[y + r][x + r] = dp[x + r][y + r] + 1; nxt.emplace(y + r, x + r); } int v1 = x + y + r, v2 = x - y + r; if(v1 >= 0 && v2 >= 0 && v1 < dp.size() && v2 < dp.size() && dp[x + r][y + r] + 1 < dp[x + y + r][x - y + r]){ dp[x + y + r][x - y + r] = dp[x + r][y + r] + 1; nxt.emplace(x + y + r, x - y + r); } } int ans = 1 << 30; for(int i = 0; i < dp.size(); i++) ans = min(ans, dp[i][i]); cout << (ans >> 30 & 1 ? -1 : ans) << '\n'; }