import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Main{
public static void main(String[] args) throws IOException{
BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
String[] str = bf.readLine().split(" ");
long n = Long.parseLong(str[0]);
long m = Long.parseLong(str[1]);
System.out.println(gcd(n,m)+lcm(n,m));
}
public static long gcd(long x,long y){
while(x !=0){
long temp = y%x;
y = x;
x = temp;
}
return y;
}
public static long lcm(long x,long y){
long s = gcd(x,y);
return x*y/s;
}
}
import java.io.IOException;
import java.io.InputStreamReader;
public class Main{
public static void main(String[] args) throws IOException{
BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
String[] str = bf.readLine().split(" ");
long n = Long.parseLong(str[0]);
long m = Long.parseLong(str[1]);
System.out.println(gcd(n,m)+lcm(n,m));
}
public static long gcd(long x,long y){
while(x !=0){
long temp = y%x;
y = x;
x = temp;
}
return y;
}
public static long lcm(long x,long y){
long s = gcd(x,y);
return x*y/s;
}
}