import sys

input = sys.stdin.readline

# int(input()) # 入力が1つ

a, b = list(map(int, input().split())) # 入力が複数

# [int(i) for i in input().split()] # 配列で数字

# 公約数の中から、素数を選べばいいのかな。





def is_prime(num):

    if num == 2:

        return True

    if num < 2 or num % 2 == 0:

        return False

    sqrt_num = num ** 0.5

    i = 2

    while i <= sqrt_num:

        if num % i == 0:

            return False

        i += 1

    return True



def lc(n):

    l = set()

    i = 1

    while i ** 2 <= n:

        if n % i == 0:

            l.add(i)

            l.add(n // i)

        i += 1

    return l

A = lc(a)

B = lc(b)

LC = list(A & B)



primes = []

for n in LC:

    if n == 1:

        primes.append(n)

    elif is_prime(n):

        primes.append(n)

ans = len(primes)

print(ans)
# https://atcoder.jp/contests/abc142/tasks/abc142_d

def prime_factorize(n):

    a = []

    while n % 2 == 0:

        a.append(2)

        n //= 2

    f = 3

    while f * f <= n:

        if n % f == 0:

            a.append(f)

            n //= f

        else:

            f += 2

    if n != 1:

        a.append(n)

    return a



def nC2(n):

    return n * (n - 1) // 2



a, b = list(map(int, input().split()))



A = set(prime_factorize(a))

B = set(prime_factorize(b))



common = A & B

common.add(1)

ans = len(common)

print(ans)
import sys

input = sys.stdin.readline
# int(input()) # 入力が1つ
a, b = list(map(int, input().split()))  # 入力が複数
# [int(i) for i in input().split()] # 配列で数字
# 公約数の中から、素数を選べばいいのかな。
def is_prime(num):
    if num == 2:
        return True
    if num < 2 or num % 2 == 0:
        return False
    sqrt_num = num**0.5
    i = 2
    while i <= sqrt_num:
        if num % i == 0:
            return False
        i += 1
    return True


def lc(n):
    l = set()
    i = 1
    while i**2 <= n:
        if n % i == 0:
            l.add(i)
            l.add(n // i)
        i += 1
    return l


A = lc(a)
B = lc(b)
LC = list(A & B)
primes = []
for n in LC:
    if n == 1:
        primes.append(n)
    elif is_prime(n):
        primes.append(n)
ans = len(primes)
print(ans)

# https://atcoder.jp/contests/abc142/tasks/abc142_d
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a


def nC2(n):
    return n * (n - 1) // 2


a, b = list(map(int, input().split()))
A = set(prime_factorize(a))
B = set(prime_factorize(b))
common = A & B
common.add(1)
ans = len(common)
print(ans)

-import sys - -input = sys.stdin.readline -# int(input()) # 入力が1つ -a, b = list(map(int, input().split()))  # 入力が複数 -# [int(i) for i in input().split()] # 配列で数字 -# 公約数の中から、素数を選べばいいのかな。 -def is_prime(num): -    if num == 2: -        return True -    if num < 2 or num % 2 == 0: -        return False -    sqrt_num = num**0.5 -    i = 2 -    while i <= sqrt_num: -        if num % i == 0: -            return False -        i += 1 -    return True +# https://atcoder.jp/contests/abc142/tasks/abc142_d +def prime_factorize(n): +    a = [] +    while n % 2 == 0: +        a.append(2) +        n //= 2 +    f = 3 +    while f * f <= n: +        if n % f == 0: +            a.append(f) +            n //= f +        else: +            f += 2 +    if n != 1: +        a.append(n) +    return a -def lc(n): -    l = set() -    i = 1 -    while i**2 <= n: -        if n % i == 0: -            l.add(i) -            l.add(n // i) -        i += 1 -    return l +def nC2(n): +    return n * (n - 1) // 2 -A = lc(a) -B = lc(b) -LC = list(A & B) -primes = [] -for n in LC: -    if n == 1: -        primes.append(n) -    elif is_prime(n): -        primes.append(n) -ans = len(primes) +a, b = list(map(int, input().split())) +A = set(prime_factorize(a)) +B = set(prime_factorize(b)) +common = A & B +common.add(1) +ans = len(common)