#include <bits/stdc++.h>
using namespace std;

int gcd(int n, int m) {return (m == 0? n : gcd(m, n % m));}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  int x, y;
  cin >> x >> y;
  cout << (x + 1) + y - gcd(x, y) << endl;
}
