import scala.io.StdIn

object Main extends App {
  val Array(a, b) = StdIn.readLine().split(" ").map(_.toLong)
  val gcd_v = gcd(a, b)

  println(primeDivSize(gcd_v))
  

  def isPrime(i: Long) : Boolean = {
    if (i == 2l)
      true
    else
      !(2l to (i-1l)).exists(x => i % x == 0l)
  }

  def primeDivSize(i: Long) : Int = {
    val range :Long = Math.sqrt(i).ceil.toLong
    var target = i
    val ans :scala.collection.mutable.Set[Long] = scala.collection.mutable.Set[Long](1)
    var j = 2
    while (j <= range) {
      if (target % j == 0) {
        ans += j
        target = target / j }
      else j = j + 1
    }

    if (target != 1) ans += target

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

