object Main {
  def main(args:Array[String]) {
    val ab = readLine().split(' ').map(_.toLong)
    val loop = ab.toList.min
    var count = 0
    var ans_count = 1
    for(i <- 2l to loop / 2) {
      if(ab(0) % i == 0 && ab(1) % i == 0) {
        count = 0
        for(j <- 2l to i) {
          if(i % j == 0) count += 1
        }
        if(count == 1) ans_count += 1
      }
    }
    println(ans_count)
  }
}


