#include<stdio.h>

int GCD(int x, int y) {
	if (y == 0)
		return x;
	else
		return GCD(y, x%y);
}

int main()
{
	int x, y, g;
	scanf("%d %d", &x, &y);
	g = GCD(x, y);
	x = x / g;
	y = y / g;
	printf("%d\n", 1 + (x + y - 1)*g);
	return 0;
}