fun main() {
    val (a, b) = readLongs()
    val gcd = gcd(a, b)

    val primeFactors = primeFactors(gcd)
    println(primeFactors.size + 1)
}

fun factorise(nn: Long): List<Long> {
    val factors = mutableListOf<Long>()
    var x = 2L
    var n = nn
    while (x * x <= n) {
        while (n % x == 0L) {
            factors.add(x)
            n /= x
        }
        x++
    }
    if (n > 1) factors.add(n)
    return factors
}

fun primeFactors(n: Long): Map<Long, Int> {
    val factors = factorise(n)
    val occurrences = mutableMapOf<Long, Int>()
    factors.forEach { factor -> occurrences[factor] = occurrences[factor]?.plus(1) ?: 1 }
    return occurrences
}

fun gcd(a: Long, b: Long): Long {
    if (b == 0L) return a
    return gcd(b, a % b)
}

// Input Reader
private fun readLn() = readLine()!!

private fun readStrings() = readLn().trim().split(" ")
private fun readLongs() = readStrings().map { it.toLong() }
