#include <bits/stdc++.h>
#define rep(i,n) for (long long i = 0; i < (n); ++i)
const int INF = 2147483647;//int max
const long long int MOD = 1000000007;
using namespace std;
using ll = long long;
using P = pair<int,int>;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
ll _gcd(ll x, ll y){
    while(1){
        if(x%y == 0)return y;
        else{
            ll z = x%y;
            x = y;
            y = z;
        }
    }
}
//ミョ(-ω- ?)
int main() {
    ll x,y;
    cin >> x >> y;
    cout << x + y - _gcd(x,y)+1 << endl;
    return 0;
}
