#include<bits/stdc++.h>
using namespace std;

using ll=long long;
using ull=unsigned long long;
using i128=__int128_t;
using u128=__uint128_t;
using ld=long double;

bool dfs(int x, int y, set<pair<int, int>>& visited, int depth = 0, int maxDepth = 100) {
    if(depth > maxDepth) return false;  // 深度限制
    if(x == y) return true;
    
    pair<int, int> state = {x, y};
    if(visited.count(state)) return false;  // 避免循环
    visited.insert(state);
    
    // 尝试所有可能的下一步
    if(dfs(y, x, visited, depth + 1, maxDepth)) return true;
    if(dfs(x + y, x - y, visited, depth + 1, maxDepth)) return true;
    
    return false;
}

void solve()
{
	int x,y;//通过上面的DFS打表 可以发现如果两个数绝对值不相等 或者其中没有0的话 是绝对不能变换成功的
	cin >> x >> y;
	if(x==y)
	{
		cout << 0;
	}
	else if(x==0)
	{
		cout << 2;
	}
	else if(y==0)
	{
		cout << 1;
	}
	else if(x==-y)
	{
		cout << 3;
	}
	else cout << -1;


}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	
	int t=1;
	//cin >> t;
	
	while(t--)
	{
		solve();
	}
	return 0;
}