tailrec fun gcd(a: Long, b: Long): Long = if (b == 0L) a else gcd(b, a % b)

fun factorize(n0:Long):List<Pair<Long,Int>>{
    val res = mutableListOf<Pair<Long, Int>>()
    var i = 2L
    var n = n0
    while (i * i <= n) {
        if (n % i != 0L){
            i++
            continue
        }
        var c = 0
        while ( n % i == 0L){
            n /= i
            c++
        }
        res.add(i to c)
        i ++
    }
    if (n != 1L){
        res.add(n to 1)
    }
    return res
}


fun calc(a:Long, b:Long):Int = factorize(gcd(a, b)).size + 1

fun main(args:Array<String>) {
    val (a, b) = readLine()!!.split(" ").map { it.toLong() }
    val ans = calc(a, b)
    println(ans)
}
