[<AutoOpen>]
module Program

open System

let read f = stdin.ReadLine() |> f
let reada f = stdin.ReadLine().Split() |> Array.map f
let reads f = stdin.ReadLine().Split() |> Array.toList |> List.map f

let inline gcd x y =
    let zero = LanguagePrimitives.GenericZero
    let rec loop x y = if y = zero then x else loop y (x % y)
    loop (abs x) (abs y)

let factorize n =
    let rec loop acc m i =
        if i * i > n then
            Set.add m acc
        else
            match (m / i, m % i) with
            | (q, 0L) -> loop (Set.add i acc) q i
            | _ -> loop acc m (i + 1L)
    loop Set.empty n 2L
    |> Set.remove 1L

[<EntryPoint>]
let main _ =
    let [a;b] = reads int64
    gcd a b
    |> factorize
    |> Set.count
    |> (+) 1
    |> stdout.WriteLine
    0