#include<iostream>
using namespace std;

int gcd(int x, int y){
  if(y==0)
    return x;

  return gcd(y, x%y);
}

int main(){
  int x, y;
  cin >> x >> y;

  int g = gcd(x, y);

  cout << (x+1)+(y+1)-(g+1) << endl;

  return 0;
}

