open System

[<AutoOpen>]
module Cin =
    let read f = stdin.ReadLine() |> f
    let reada f = stdin.ReadLine().Split() |> Array.map f

let rec gcd x y =
    if y = 0 then x
    else gcd y (x % y)

let primeFactors n =
    let limit = n |> float |> sqrt |> int
    let rec count x p acc =
        if x % p = 0 then count (x / p) p (acc + 1)
        else acc
    let mutable n = n
    let res =
        seq {
            for p in 2..limit do
                let c = count n p 0
                if c <> 0 then
                    n <- n / (p * c)
                    yield (p, c)
        } |> Map.ofSeq
    if n = 1 then res
    else res.Add (n, 1)

[<EntryPoint>]
let main _ =
    let [|A;B|] = reada int
    let primes = gcd A B |> primeFactors
    primes.Count + 1
    |> printfn "%d"
    0
