import java.io.{BufferedReader, InputStreamReader}

object Main {
  def main(args: Array[String]): Unit = {
    val in = new BufferedReader(new InputStreamReader(System.in))
    val Array(a, b) = in.readLine().split("\\s+").map(_.toLong)

    System.out.println((prime(a).toSet & prime(b).toSet).size + 1)
  }


  def prime(n: Long): List[Long] = {
    def _prime(n: Long, ps: List[Long]): List[Long] = {
      (2 to Math.sqrt(n).toInt).find(n % _ == 0) match {
        case Some(p) => _prime(n / p, p :: ps)
        case None => n :: ps
      }
    }

    _prime(n, Nil)
  }
}
