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

fun factorization(n :Long) :List<Long>{
    var number = n
    val list = mutableListOf<Long>()
    while (number % 2L == 0L) {
        list.add(2L)
        number /= 2
    }
    for(divider in 3L..(Math.floor(Math.sqrt(number.toDouble())) + 1f).toLong()  step 2){
        while (number % divider == 0L) {
            list.add(divider)
            number /= divider
        }
        if (number == 1L){
            break
        }
    }
    if (number != 1L){
        list.add(number)
    }
    return list
}

fun calc(a:Long, b:Long):Int = factorization(gcd(a, b)).toSet().size + 1

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


