#include <stdio.h>
int main()
{
	long long n = 0, m = 0;
	scanf("%ld %ld", &n, &m);
	if (n < m)
	{
		int temp = n;
		n = m;
		m = temp;
	}
	long long q = n*m;
	while (m!=0)
	{
		int t = n%m;
		n = m;
		m = t;
	}
	long long  max = n;
	long long min = q / n;
	printf("%lld\n", max+min);
	return 0;
}