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

    var cnt = 1L
    fa.forEach { m ->
        if (fb[m.key] != null) cnt++
    }

    println(cnt)
}

fun factors(value: Long): Map<Long, Long> {
    val factors = mutableMapOf<Long, Long>()
    val max = Math.sqrt(value.toDouble()).toLong()
    var tmp = value

    for (i in 2..max) {
        while (tmp % i == 0L) {
            tmp /= i
            factors[i] = (factors[i] ?: 0) + 1
        }
    }

    if (tmp != 1L) {
        factors[tmp] = 1
    }

    return factors
}
