const getGCD = (a, b) => {
    if (b === 0) return a;
    else if (a === 0) return b;
    return getGCD(b, a%b);
    
}

const getDivisors = (n) => {
    let ret = []
    for(let i=1; i*i<=n; i++) {
        if(n%i===0) {
            ret.push(i)
            if(i!==n/i)
              ret.push(n/i)
        }
    }
    return ret
}

const isPrime = (n) => {
    for(let i=2; i*i<=n; i++) {
        if(n%i===0)return false
    }
    return true
}

const main = (arg) => {
    let [a,b] = arg.split(" ").map(Number)
    let gcd = getGCD(a,b)
    // console.log(gcd)
    let divs = getDivisors(gcd)

    divs.sort((a,b)=>a-b)
    // console.log(divs)
    let ans=0
    for(let i=0; i<divs.length; i++) {
        if(isPrime(divs[i])) ans++
    }
    console.log(ans)
    
}
main(require("fs").readFileSync("/dev/stdin", "utf8"));