import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        while(in.hasNext()){
            long n=in.nextInt();
            long m=in.nextInt();
            long gcd= gcd1(n,m);
            long lcm= lcm( n,m);
            long sum=gcd+lcm;
            System.out.println(sum);
        }
    }
    //递归
    public static long gcd1(long n,long m){
        return m==0?n:gcd1(m,n%m);
    }
    //欧几里得
    public static long gcd2(long n,long m){
        while(m>0){
            long temp=n%m;
            n=m;
            m=temp;
        }
        return n;
    }
    public static long lcm(long n,long m){
        return (n*m)/gcd1(n,m);
    }
}