[<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

#nowarn "40"
let rec primes =
    let rec loop n = seq {
        yield! List.filter isPrime [6L * n - 1L; 6L * n + 1L]
        yield! loop (n + 1L)
    }
    seq {
        yield 2L
        yield 3L
        yield! loop 1L
    }
    |> Seq.cache
and isPrime n =
    let ps = Seq.takeWhile (fun x -> x * x <= n) primes
    Seq.forall (fun x -> n % x <> 0L) ps

let factorize n =
    let mutable m = n
    seq {
        for p in Seq.takeWhile (fun x -> x * x <= n) primes do
            while m % p = 0L do
                yield p
                m <- m / p
        if m > 1L then yield m
    }

[<EntryPoint>]
let main _ =
    let [a;b] = reads int64
    let sa = factorize a |> Set.ofSeq
    let sb = factorize b |> Set.ofSeq
    Set.intersect sa sb
    |> Set.count
    |> (+) 1
    |> printfn "%i"
    0