fun main(args: Array<String>) {
    val (a, b) = readLine()!!.split(" ").map(String::toLong).sorted()
    val greatestCommonDiv = gcd(a, b)

    val primes = greatestCommonDiv.getDisjointDividers()

    println(1 + primes.size)
}

tailrec fun gcd(a: Long, b: Long): Long {
    return when (a) {
        0L -> b
        else -> gcd(b % a, a)
    }
}

fun Long.getDisjointDividers(): Set<Long> {
    var divider = 2L
    var n = this
    val dividers = mutableSetOf<Long>()


    while (divider * divider <= this) {
        if (n % divider != 0L) {
            divider += 1L
            continue
        }
        while (n % divider == 0L) n /= divider
        dividers += divider
        divider += 1L
    }

    if (n > 1L) dividers += n

    return dividers
}