/*
12 50
50 % 12 = 2
12 % 2 = 6
2 % 6 = 2
6 % 2 = 3;
2 % 3 = 2;
3 % 2 = 1;
2 % 1 = 0
*/
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
long n = (long)sc.nextInt();
long m = (long)sc.nextInt();
long maxYue = 1; // 描述最大公约数
long minBei = n * m; // 描述最小公倍数
// 保持 n大m小
if(n < m) {
long t = m;
m = n;
n = t;
}
// 辗转相除计算最大公约数
long r = m % n;
while(r != 0) {
m = n;
n = r;
r = m % n;
}
maxYue = n;
// 求最小公倍数
minBei = minBei / maxYue;
System.out.println(maxYue + minBei);
}
}