object Main {
  def main(args:Array[String]) {
    val ab = readLine().split(' ').map(_.toLong)
    var g:Long = gcd(ab(1), ab(0))
    var ans = 1
    var loop = math.sqrt(g).toLong + 1
    for(i <- 2l to loop) {
      var flag = false
      while(g % i == 0) {
        flag = true
        g /= i
      }
      if(flag) ans += 1
    }
    if(g != 1) ans += 1
    println(ans)
  }

  def gcd(a:Long, b:Long):Long ={
    if(a == 0) b
    else gcd(b % a, a)
  }
}
