/*


	int n;
	cin >> n;
	int j = 1;
	int m = 1;

	for(int i=0;i<n;i++){
		int a;
		cin >> a;

		if( a == 1 ){
			j++;
			m = max(m,j);
		}
		else{
			j = 1;
		}
	}

	cout << m << endl;

	return 0;
}
*/

/*


	int n,m,x,y,z;
	cin >> n >> m;
	x = 0;
	y = 0;
	z = 0;
	for(int i=0;i<m;i++){
		int a,b;
		cin >> a >> b;

		if( a < n ){
			x = x+(n-a);
			y = n-a;
			z = max( z , y );
		}
	}

	cout << x-z << endl;

	return 0;
}
*/

/*
#include <iostream>
using namespace std;
int main(){

	string s;
	

	return 0;
}
*/

/*


	int a,b,c,d,e,f,g,h,s,t;
	cin >> a >> b >> c >> d >> e >> f >> g >> h;
	s = a+b+c+d;
	t = e+f+g+h;

	if(s >= t){
		cout << s << endl;
	}
	else{
		cout << t << endl;
	}

	return 0;
}
*/

/*


	int n;
	cin >> n;

	while()

	return 0;
}

*/

/*

#include <set>
using namespace std;
int main(){
	int n,m;
	cin >> n;

	set<int> A;

	for(int i=0; i<n; i++){
		int a;
		cin >> a;
		
		A.insert(a);
	}
	m = A.size();

	cout << m << endl;
	
	return 0;
}
*/


/*


	while(true){

	int n,m;
	cin >> n;
	if(n == 0) return 0;
	m = 0;
	n = 1000-n;

	if(n>=500){
		m = n/500;
		n = n%500;
	}
	if(n>=100){
		m = m+n/100;
		n = n%100;
	}
	if(n>=50){
		m = m+n/50;
		n = n%50;
	}
	if(n>=10){
		m = m+n/10;
		n = n%10;
	}
	if(n>=5){
		m = m+n/5;
		n = n%5;
	}
	if(n>=1){
		m = m+n/1;
	}

	cout << m << endl;

	}

}
*/


/*
#include<iostream>
using namespace std;
int main(){
	
	for(int i=0; i<5; i++){
		int N,A,B,C,D,E,F,G,H,I;
		cin >> N >> A >> B >> C >> D >> E >> F >> G >> H >> I;

		if(N == 0)break;

		cout << N-A-B-C-D-E-F-G-H-I << endl;
}
	
	return 0;
}
*/

/*
#include<iostream>
#include <algorithm>
using namespace std;
int main(){
	int n,a,b,c,d;
    cin >> n;

	int A[1000];
	int B[1000]; 


	for (int i=0; i<n; i++){
		A[i] = 0;
		B[i] = 0;
	}


	for(int i=0; i<n*(n-1)/2; i++){
		cin >> a >> b >> c >> d;
		if( c > d ){
			A[a-1] += 3;
			B[a-1] += 3;
		}
		else if( c < d ){
			A[b-1] += 3;
			B[b-1] += 3;
		}
		else{
			A[a-1] ++;
			A[b-1] ++;
			B[a-1] ++;
			B[b-1] ++;
		}
	}

	sort(A,A+1000);
	reverse(A,A+1000);

	int x = 0;

	for(int i=0; i<n; i++){
		for(int j=0; j<n; j++){
			x++;
			if(B[i] == A[j]){
				cout << x << endl;
				x = 0;
				break;
			}
			
		}
	}

	return 0;
}
*/

/*
//気象予報士
#include<iostream>
#include <algorithm>
#include<string>
using namespace std;
int main(){

	int h,w;
	cin >> h >> w;

	for( int k=0; k<h; k++){
			string A;
			cin >> A;

		for(int i=0; i<w; i++){
	
			if(i == 0 && A[0] == 'c'){
				cout << 0;
			}
			else if(i == 0){
				cout << -1;
			}
	
			if( i != 0 && A[i] == 'c'){
				cout << " " << 0;
			}
			else if(i != 0){
	
				for(int j=0; j<i; j++){
	
					if(A[i-j+1] == 'c'){
					cout << " " << j;
					break;
					}

					cout << " " << -1;
				}
			}
			cout << endl;
		}

	}

	return 0;
}
*/

/*

#include<iostream>
#include <algorithm>
#include<string>
using namespace std;
int main(){

	for(int DATA=0; DATA<5; DATA++){

			int n,m;
			cin >> n >> m;

			int N[1500];
			for(int i=0; i<n; i++){
				cin >> N[i];
			}

			int t=1,x=0;
			for(int i=0; i<m; i++){
				int M;
				cin	>> M;
					
					x += M;
					if( x >= n-1 ){
						cout << t << endl;
						break;
					}
	
					x += N[x];
					if( x >= n-1 ){
						cout << t << endl;
						break;
					}

					t++;
			}
	}
	return 0;
}

*/

/*超都観光
#include<iostream>
#include <algorithm>
#include<string>
using namespace std;
int main(){

	int w,h,n,t,X,Y;
	cin >> w >> h >> n;

	for(int i=0; i<n; i++){
		int x,y;
		cin >> x >> y;

		if(i == 0){
			t=0;
		}

		else{
			if( (x-X)*(y-Y) >= 0){
				t += min(abs(x-X),abs(y-Y));
				t += max(abs(x-X),abs(y-Y))-min(abs(x-X),abs(y-Y));
			}
			else{
				t += abs(x-X);
				t += abs(y-Y);
			}
		}
		X=x;
		Y=y;

	}

	cout << t << endl;

	return 0;
}


/*スーパーコン
#include<stdio.h>
#include<stdlib.h>
#include "sc1.h"
using namespace std;
int main(){

	void scInput();

	int x[19],y[19];
	x[0] = 0;
	y[0] = 0;

	for(int i=0; i<18; i++){

		if(scD[i] == 0){
			x[i+1] = x[i]+1;
			y[i+1] = y[i];
		}
		if(scD[i] == 1){
			x[i+1] = x[i];
			y[i+1] = y[i]+1;
		}
		if(scD[i] == 2){
			x[i+1] = x[i]-1;
			y[i+1] = y[i];
		}
		if(scD[i] == 3){
			x[i+1] = x[i];
			y[i+1] = y[i]-1;
		}

		for(int j=0; j<i+1; j++){
			if(x[i+1] == x[j] && y[i+1] == y[j]){
				void scOutput(int s=0);
			}
		}

	}
	void scOutput(int S=1);
}
*/

/*
#include <algorithm>
#include<vector>
#include<utility>
#include<iostream>
#include<string>
using namespace std;
int main(){

	int n,m;
	cin >> n >> m;

	vector<pair<int,int>> A;

	for(int i=0; i<n; i++){
		int xt,yt;
		cin >> xt >> yt;
		A.push_back(make_pair(xt,yt));
	}

	for(int i=0; i<m; i++){
		int xs,ys,xf,yf,t;
		t = 0;
		cin >> xs >> ys >> xf >> yf;

		for(int j=0; j<n; j++){
			if( A[j].first-(xs-1) * xf-A[j].second * A[j].first-(ys-1) * yf-A[j].second > 0){//宝物が範囲の中にあったら
				t++;
			}
			cout << t << endl;

		}

	}

	return 0;

}
*/

/*
#include<string>
#include<iostream>
using namespace std;
int main(){

	for(int j=0; j<5; j++){

		string A;
		cin >> A;

		if(A == "EOF")return 0;

		int joi = 0,ioi = 0;

		for(int i=0; i<A.size(); i++){
			if( (A[i] == 'J' && A[i+1]  == 'O') && A[i+2] == 'I' )joi++;
			if( (A[i] == 'I' && A[i+1]  == 'O') && A[i+2] == 'I' )ioi++;
		}

		cout << joi << endl << ioi << endl;

	}

	return 0;
}
*/

/*

	for(int i=0; i<3; i++){
		int hs,ms,ss,hf,mf,sf;
		cin >> hs >> ms >> ss >> hf >> mf >> sf;

		int S,F,Th,Tm,Ts,t;

		Th = 0;
		Tm = 0;
		Ts = 0;

		S = 3600*hs+60*ms+ss;
		F = 3600*hf+60*mf+sf;
		t = F-S;

		while( t > 3600){
			Th++;
			t-=3600;
		}
		while( t > 60){
			Tm++;
			t-=60;
		}
		Ts = t;

		cout << Th << " " << Tm << " " << Ts << endl;

	}

	return 0;
}
*/

#include<iostream>
using namespace std;

int uclid(int x,int y){
	int X,Y;
	X = max(x,y);
	Y = min(x,y);

	if(X%Y==0) return Y;

	int ans=X%Y;
	uclid(ans,Y);

}


int main(){

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


	return 0;
}


Measured memory_bytes: 3116