func gcd(_ m: Int, _ n: Int) -> Int {
    var a: Int = 0
    var b: Int = max(m, n)
    var r: Int = min(m, n)

    while r != 0 {
        a = b
        b = r
        r = a % b
    }
    return b
}

let arr=readLine()!.characters.split{$0==" "}.map{Int(String($0))!}

var yakusu : [Int] = []
var ans : [Int] = [1]

var i = 0
var j = 0
let min_arr = min(arr[0],arr[1]) 
var max_i = 0
for i in 1..<min_arr {
  if ( ( arr[0] % i == 0 ) && ( arr[1] % i == 0 ) ) {
    yakusu.append(i)
    for j in 0..<yakusu.count-1 {
      //print( j, yakusu.count-1, i, yakusu[j], gcd( i, yakusu[j] ) )
      if( gcd( i, yakusu[j] ) != 1) {
        //ans.append(i)
        break
      }
		if( j + 1 == yakusu.count - 1  ) {
        ans.append(i)
      }
    }      
       
    max_i = i
  }
}

print( ans.count )
