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

val memo = hashMapOf<Int, Long>()
fun generatePrime(index: Int): Long {
    if (index == 0) {
        return 2
    }
    if (index == 1) {
        return 3
    }
    memo[index]?.let {
        return it
    }
    val prev = generatePrime(index - 1)
    var next = prev + 2
    var i = 0
    var prime = 0L
    var l = Math.sqrt(next.toDouble()).toLong()
    while (i < index - 1 && l > prime) {
        prime = generatePrime(++i)
        if (next % prime == 0L) {
            next += 2
            i = 1
            l = Math.sqrt(next.toDouble()).toLong()
        }
    }
    memo[index] = next
    return next
}

fun isPrime(candidate: Long): Boolean {
    var i = 0
    var prime = 0L
    val l = Math.sqrt(candidate.toDouble()).toLong()
    while (l > prime) {
        prime = generatePrime(++i)
        if (candidate % prime == 0L) {
            return false
        }
    }
    return true
}

fun main(args: Array<String>) {
    val (a, b) = readLine()?.split(" ")?.map(String::toLong) ?: return
    var l = gcd(a, b)
    var i = 0
    val primes = mutableSetOf<Long>()
    if (l != 1L && isPrime(l)) {
        println("2")
        return
    }
    var p = 0L
    val e = Math.sqrt(l.toDouble()).toLong()
    var end = false
    while ((l != 1L || p < e) && !end) {
        p = generatePrime(i)
        while (l % p == 0L) {
            l /= p
            primes.add(p)
            end = isPrime(l)
        }
        i++
    }
    if (l != 1L) {
        println((primes.size + 2).toString())
    } else {
        println((primes.size + 1).toString())
    }
}

