import java.util.*

fun main(args : Array<String>) {
    val scanner = Scanner(System.`in`)
    val a = scanner.nextLong()
    val b = scanner.nextLong()
    val gcd = if (a > b) gcd(a, b) else gcd(b, a)
    println(factorize(gcd).size + 1)
}

tailrec fun gcd(large: Long, small: Long): Long {
    if (small == 0L) return large
    return gcd(small, large % small)
}

fun factorize(l: Long): List<Pair<Long, Int>> {
    var target = l
    val mutableList = mutableListOf<Pair<Long, Int>>()

    for (i in 2..l) {
        if (target == 1L) break
        if (i * i > l) break
        if (target % i != 0L) continue

        var multiCount = 0
        while (target % i == 0L) {
            target = target / i
            multiCount += 1
        }

        mutableList.add((i to multiCount))
    }

    if (target != 1L) mutableList.add((target to 1))

    return mutableList
}