function Main(input) {
    input = input.split(" ");        
    input = input.map(e=>parseInt(e,10));

    var maxKouyaku = saiki(input[1],input[0]);    

    var kouyaku = [];

    if(maxKouyaku%2 == 0){
        kouyaku.push(2);
        for(var i=3;i<=maxKouyaku;i+=2){
            if(maxKouyaku%i==0 && !kouyaku.some(e=>i%e==0))kouyaku.push(i);
        }
    }else{
        for(var i=2;i<=maxKouyaku;i++){
            if(maxKouyaku%i==0 && !kouyaku.some(e=>i%e==0))kouyaku.push(i);
        }
    }    

    var result = kouyaku.filter(e=>{ 
        return !kouyaku.some(f=>{            
            return f!=e && e%f==0;
        })        
    })    
    console.log(result.length+1);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

function saiki(num,shou){    
    if(num%shou==0)return shou;
    return saiki(shou,num%shou)
}