from math import sqrt, ceil

import fractions

A, B = list(map(int, input().split()))





def is_prime(n):

    if n == 1:

        return False

    for i in range(2, int(n**0.5)+1):

        if n % i == 0:

            return False

    return True





def make_divisors(n):

    divisors = []

    for i in range(1, int(n**0.5)+1):

        if n % i == 0:

            divisors.append(i)

            if i != n // i:

                divisors.append(n//i)



    return divisors





ans = 1



tmp = make_divisors(fractions.gcd(A, B))



for x in tmp:

    if is_prime(x):

        ans += 1



print(ans)

def main():

    import fractions

    import math

    A, B = list(map(int, input().split()))



    gcd = fractions.gcd(A, B)



    tmp = gcd

    ans = 1

    for i in range(2, int(-(-gcd**0.5//1))+1):

        if tmp % i == 0:

            ans += 1

            while(tmp % i == 0):

                tmp = tmp//i

    if tmp != 1:

        ans += 1

    print(ans)





main()

from math import sqrt, ceil
import fractions

A, B = list(map(int, input().split()))


def is_prime(n):
    if n == 1:
        return False
    for i in range(2, int(n**0.5) + 1):
        if n % i == 0:
            return False
    return True


def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5) + 1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n // i)
    return divisors


ans = 1
tmp = make_divisors(fractions.gcd(A, B))
for x in tmp:
    if is_prime(x):
        ans += 1
print(ans)

def main():
    import fractions
    import math

    A, B = list(map(int, input().split()))
    gcd = fractions.gcd(A, B)
    tmp = gcd
    ans = 1
    for i in range(2, int(-(-(gcd**0.5) // 1)) + 1):
        if tmp % i == 0:
            ans += 1
            while tmp % i == 0:
                tmp = tmp // i
    if tmp != 1:
        ans += 1
    print(ans)


main()

-from math import sqrt, ceil -import fractions +def main(): +    import fractions +    import math -A, B = list(map(int, input().split())) +    A, B = list(map(int, input().split())) +    gcd = fractions.gcd(A, B) +    tmp = gcd +    ans = 1 +    for i in range(2, int(-(-(gcd**0.5) // 1)) + 1): +        if tmp % i == 0: +            ans += 1 +            while tmp % i == 0: +                tmp = tmp // i +    if tmp != 1: +        ans += 1 +    print(ans) -def is_prime(n): -    if n == 1: -        return False -    for i in range(2, int(n**0.5) + 1): -        if n % i == 0: -            return False -    return True - - -def make_divisors(n): -    divisors = [] -    for i in range(1, int(n**0.5) + 1): -        if n % i == 0: -            divisors.append(i) -            if i != n // i: -                divisors.append(n // i) -    return divisors - - -ans = 1 -tmp = make_divisors(fractions.gcd(A, B)) -for x in tmp: -    if is_prime(x): -        ans += 1 -print(ans) +main()