open System.Collections.Generic

let reads f = stdin.ReadLine().Split() |> Array.map f

let f (ls: List<int64>) (v:int64) : bool =
    let rec loop xs b =
        if not b then b
        else match xs with
             | [] -> b
             | y::ys -> if v % y = 0L then false else loop ys true
    loop (List.ofSeq ls) true

let [| a; b; |] = reads int64
let ls = List<int64>()
for i in [2L .. (if a < b then a else b)] do
    if a % i = 0L && b % i = 0L then
        if f ls i then ls.Add i
printfn "%d" (ls.Count+1)