#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;

int gcd(int a,int b){
	if(!b)return a;
	return gcd(b,a%b);
}
int main(){
	int x,y;cin>>x>>y;
	int g=gcd(x,y);
	cout<<(x/g+y/g-1)*g+1<<endl;
}