#define _CRT_SECURE_NO_WARNINGS #include "bits/stdc++.h" using namespace std; int main() { int M, N; cin >> M >> N; int ans = 0; while (N != M){ ans++; if (M >= N) M -= N; else swap(M, N); } if (M == 0 || N == 0) ans = -1; cout << ans << endl; }