#include #include #include #include #include #include #include #include #include #include using namespace std; using ll = long long; #define rep(i, n) for (ll i = 0; i < n; i++) const ll INF = 1LL << 60; typedef pair P; bool pairCompare(const P& firstElof, const P& secondElof) { return firstElof.second < secondElof.second; } bool IsPrime(ll num) { if (num < 2) return false; else if (num == 2) return true; else if (num % 2 == 0) return false; // 偶数はあらかじめ除く double sqrtNum = sqrt(num); for (int i = 3; i <= sqrtNum; i += 2) { if (num % i == 0) { // 素数ではない return false; } } // 素数である return true; } bool hako[10005] = { false }; signed main() { ll ans = 0; ll a, b; cin >> a >> b; for (ll i = 1; i <= 100; i++) { if (a % i == 0 && b % i == 0) { cout << -1 << endl; return 0; } } rep(i, b) { rep(j, a) { hako[a * i + b * j] = true; } } rep(i, a * b) { if (hako[i] == false) { ans++; } } cout << ans << endl; }