let [| a; b; |] = stdin.ReadLine().Split() |> Array.map int64

let gcd a b =
    let rec f a b=
        match a - b with
        | 0L -> a
        | x when x > 0L -> f x b 
        | x when x < 0L -> f a -x
    f a b

let primeList n =
    let rec f (seq:list<int64>) resultList=
        if  seq|>List.isEmpty then resultList
        else
        f  (seq |> List.filter (fun x -> x % (seq|>List.head ) <> 0L)) ((seq|>List.head)::resultList)
    f [2L..n] List.Empty

let factorization n =
    if n = 1L then Set.empty
    else
    let pArray = primeList n |> List.rev |> List.toArray 
    let rec f i m (result:Set<_>)=
        match pArray.Length - i , m % pArray.[i] with
        |1, 0L -> f 0 (m/pArray.[i]) (result.Add(pArray.[i]))
        |1, _ -> result
        |_, 0L -> f 0 (m/pArray.[i]) (result.Add(pArray.[i]))
        |_, _ -> f (i+1) m result
    f 0 n Set.empty

(gcd a b |>factorization |> Set.count) + 1 |> stdout.WriteLine