fun main(args: Array<String>) {
    solve(java.util.Scanner(System.`in`))
}

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

object Primes : Iterable<Long> {
    private var checked = 2L
    private val xs = mutableListOf(2L)

    fun get(i: Int): Long {
        while (xs.count() <= i) {
            var n = checked + 1
            loop@ while (true) {
                for (j in xs) {
                    if (j * j > n) {
                        break@loop
                    }
                    if (n % j == 0L) {
                        n++
                        break
                    }
                }
            }
            xs.add(n)
            checked = n
        }
        return xs[i]
    }

    override fun iterator(): Iterator<Long> = object : Iterator<Long> {
        var i = 0
        override fun hasNext(): Boolean = true
        override fun next(): Long {
            val x = get(i)
            i += 1;
            return x
        }
    }
}

fun solve(sc: java.util.Scanner) {
    val A = sc.nextLong()
    val B = sc.nextLong()

    var ans = 1
    val it = Primes.iterator()
    var a = gcd(A, B)
    do {
        val p = it.next()

        if ((a % p) == 0L) {
            ans += 1
            do a /= p while ((a % p) == 0L)
        }
    } while (p * p <= a)
    if (a != 1L) ans++

    println(ans)
}
