#include <bits/stdc++.h>

using namespace std;

int gcd(int x, int y) {
    int r = x % y;
    while (r > 0) {
        x = y;
        y = r;
        r = x % y;
    }
    return y;
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int a, b;
    cin >> a >> b;
    int sum = a + b;
    int minus = a / gcd(a, b);
    a /= minus;
    cout << sum - a + 1 << '\n';
    return 0;
}
