import java.util.Scanner

object Main extends App{
  val sc = new Scanner(System.in)

  val a = sc.nextLong
  val b = sc.nextLong

  val g = gcd(a,b)
  val sqrtG = Math.sqrt(g).ceil.toLong

  val res =
    g match {
      case 1 => 1
      case 2 => 2
      case 3 => 2
      case gg => {
        val temp = loop( (gg, Vector(1), 2) )._2
        temp.size
      }
    }

  println(res)


  def gcd(a: Long, b: Long): Long ={
    (a,b) match{
      case (x,y) if y == 0 => x
      case (x,y) if x < y  => gcd(y, x)
      case (x,y)           => gcd(y, x % y)
    }
  }

  def loop( tuple: (Long, Vector[Long], Long)): (Long, Vector[Long], Long) = {
    val (n, vec, diviser) = tuple
    if( n == 1 ) {
      (n, vec, diviser)
    } else if (diviser > sqrtG){
      (n, vec :+ n, diviser)
    }    else {
      def divLoop(num: Long, d: Long): Long =
        if(num % d != 0) num else divLoop(num / d, d)

      val newN = divLoop(n, diviser)
      val newVec = if(newN == n) vec else vec :+ diviser

      loop((newN, newVec, diviser + 1))
    }
  }



}