fun main(args: Array<String>) {
    fun read() = readLine()!!
    fun readInt() = read().toInt()
    fun readInts() = read().split(" ").map { it.toInt() }
    fun readLongs() = read().split(" ").map { it.toLong() }
    var (a, b) = readLongs()
    var ans = 1L
    for(i in 2..1e6.toInt()) {
        if(a % i == 0L && b % i == 0L) {
            ans++
        }
        while(a % i == 0L) a /= i
        while(b % i == 0L) b /= i
    }
    if(a > 1 && b > 1) {
        if(a % b == 0L || b % a == 0L) ans++
    }
    println(ans)
}