fun main(args: Array<String>) {
    val (a,b) = readLine()!!.split(" ").map(String::toLong)
    val x = gcd(a,b)
    val list = decom(x)
    println(list.size + 1)
}

fun decom(x: Long) : MutableList<Long> {
    var value = x
    val list: MutableList<Long> = mutableListOf()
    if (value % 2L == 0L) {
        list.add(2L)
        while (value % 2L == 0L) {
            value /= 2L
        }
    }
    var i = 3L
    while (i * i <= value) {
        if ( value % i == 0L) {
            list.add(i)
            while (value % i == 0L) {
                value /= i
            }
        }
        i += 2L
    }
    if (value > 1L) {
        list.add(value)
    }
    return list
}

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