#include<stdio.h>
int gcd(int x,int y){
    int r;
	if (x < y){
        r=x;
        x=y;
        y=r;
    }
    while (y > 0){
        r = x % y;
        x = y;
        y = r;
    }
    return x;
}
int main()
{
	int x,y;
	scanf("%d%d",&x,&y);
	printf("%d\n",(x+1)+(y+1)-(gcd(x,y)+1));
	return 0;
}

