fun main(args: Array<String>){
  val input = readLine()!!.split(" ")
  val a = input[0].toLong()
  val b = input[1].toLong()

  val result = getCommonPrimeNumbers(a, b)

  println(result.keys.size+1)
}

fun primeFactorization(num: Long): Map<Long, Int>{
  val result = mutableMapOf<Long, Int>()

  var tmp = num
  var sqrt = Math.sqrt(tmp.toDouble())
  var i = 2L
  while( i <= sqrt ){
    if( tmp / i * i == tmp ){
      if( result.containsKey(i) )
        result.put(i, result.get(i)!!+1)
      else
        result.put(i, 1)
      tmp /= i
      sqrt = Math.sqrt(tmp.toDouble())
      i--
    }
    i++
  }
  if( tmp != 1L ){
    if( result.containsKey(tmp) )
      result.put(tmp, result.get(tmp)!!+1)
    else
      result.put(tmp, 1)
  }
  return result
}

fun getCommonPrimeNumbers(a: Long, b: Long): Map<Long, Int>{
  val primeNumbersA = primeFactorization(a)
  val primeNumbersB = primeFactorization(b)

  val result = mutableMapOf<Long, Int>()
  for( (k, v) in primeNumbersA )
    if( primeNumbersB.containsKey(k) )
      result.put(k, Math.min(v, primeNumbersB.get(k)!!))

  return result
}
