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

int kouyaku(int a,int b){
  if(a%b==0){return b;}
  return kouyaku(b,a%b);
}




int main(){

  int x,y;
  cin>>x>>y;
  int ans=1;  
  int a=kouyaku(x,y);
  int xd=x/a,yd=y/a;
  ans+=(xd+yd-1)*a;
  cout<<ans<<endl;
  
  
  return 0;
}

