#include <iostream>
#include <cstdio>
#include <numeric>

using namespace std;

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

int main(){
    long n,m;
    while(scanf("%d%d",&n,&m)!=EOF){
        cout<<GCD(n, m)+n*m/GCD(n, m);
    }
}