import scala.io.StdIn

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

  (1l to gcd_v).foreach {i =>
    if ((isPrime(i)) && (gcd_v % i == 0)) ans = ans + 1
  }

  println(ans)
  

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

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

