fun main(args: Array<String>) {
    val (A, B) = readLine()!!.split(" ").map(String::toLong)
    val result = mutableListOf<Long>()

    val higher = Math.max(A, B)
    val lower = Math.min(A, B)
    // 約数のList
    fun divisor(value: Long): List<Long> {
        val max = Math.sqrt(value.toDouble()).toLong()
        return (1..max)
            .filter { value % it == 0L }
            .map { listOf(it, value / it) }
            .flatten()
            .sorted()
    }

    val divisorList = divisor(lower)
    for (i in divisorList) {
        if (i == 1L) {
            continue
        }
        if (higher % i == 0L) {
            if (!result.any { i % it == 0L }) {
                result.add(i)
            }
        }
    }
    result.add(1)


    result.size.let(::println)
}