import scala.io.StdIn

object Main extends App {
  val Array(a, b) = StdIn.readLine().split(" ").map(_.toInt)
  var can : Array[Int] = Array.empty

  (1 to a.min(b)).foreach {i =>
    if (a % i == 0 && b % i == 0) can = can :+ i
  }

  println(can.filter(j => isPrime(j)).length)
  

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

