#include #include #include #include #include #include #include #include #include #include using namespace std; #define int long long int MOD = 1000000007; signed main() { cin.tie(0); ios::sync_with_stdio(false); int X, Y; cin >> X >> Y; int res = 0; queue, int> > qu; qu.push(make_pair(make_pair(X,Y), 0)); pair, int > p; res = -1; while (qu.size() > 0) { p = qu.front(); qu.pop(); if (p.first.first == p.first.second) { res = p.second; break; } if (p.second > 5)break; qu.push(make_pair(make_pair(p.first.first + p.first.second, p.first.first - p.first.second), p.second + 1)); qu.push(make_pair(make_pair(p.first.second, p.first.first), p.second + 1)); } cout << res << endl; }