#include<iostream>
using namespace std;

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

int main(){
  int x, y;
  cin >> x >> y;
  int a = gcd(x,y);
  int x1 = x/a+1;
  int y1 = y/a+1;

  if(x1==y1)
    cout << x+1 << endl;
  else
    cout << (x1+y1-3)*a+1 << endl;

  return 0;
}

