#include using namespace std; int main() { cin.tie(nullptr); ios::sync_with_stdio(false); int a, b; cin >> a >> b; if (__gcd(a, b) == 1) { bitset<10010> bs; bs[0] = 1; for (int i = 0; i < 10010; ++i) { if (i + a < 10010 and bs[i]) { bs[i + a] = 1; } if (i + b < 10010 and bs[i]) { bs[i + b] = 1; } } int res = 0; for (int i = 0; i < 10010; ++i) { res += bs[i] == 0; } cout << res << '\n'; } else { cout << "-1\n"; } }