#include <iostream>
#include <stdlib.h>
using namespace std;

int main(){
    int a,b;
    
    while(cin >> a >> b){
        
        int g,l;
        int aa,bb;
        g = l = 1;
        
        /* ?????§??¬?´???° */
        aa = a;
        bb = b;
        while(true){
            int tmp = 0;
            
            if(aa % 3 == 0 && bb % 3 == 0){
                aa /= 3;
                bb /= 3;
                tmp = 3;
            }
            else if(aa % 2 == 0 && bb % 2 == 0){
                aa /= 2;
                bb /= 2;
                tmp = 2;
            }
            
            if(g == 0){
                g = tmp;
            }
            else{
                g *= tmp;
            }
            
            if(aa <= 3 || bb <= 3){
                break;
            }
            
            if((aa % 2 != 0 && bb % 2 != 0) ||
               (aa % 3 != 0 && bb % 3 != 0)){
                break;
            }
        }
        
        /* ????°???¬?????° */
        aa = a;
        bb = b;
        while(true){
            int tmp = 0;
            
            if(aa % 3 == 0 && bb % 3 == 0){
                aa /= 3;
                bb /= 3;
                tmp = 3;
            }
            else if(aa % 2 == 0 && bb % 2 == 0){
                aa /= 2;
                bb /= 2;
                tmp = 2;
            }
            
            if(g == 0){
                l = tmp;
            }
            else{
                l *= tmp;
            }
            
            if(aa <= 3 || bb <= 3){
                l *= aa;
                l *= bb;
                break;
            }
            
            if((aa % 2 != 0 && bb % 2 != 0) ||
               (aa % 3 != 0 && bb % 3 != 0)){
                l *= a;
                l *= b;
                break;
            }
        }
        
    }
    
    return 0;
}