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

import math

def is_prime(x):
    for i in range(2, int(math.sqrt(x))+1):
        if x % i == 0:
            return False

    return True


def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1

    return lower_divisors + upper_divisors[::-1]


def gcd(a, b):

    if a == 0:
        return b
    else:
        return gcd(b%a, a)


da = make_divisors(A)
common_divisors = []

for d in da:
    if B % d == 0:
        common_divisors.append(d)

ans = [1 if is_prime(x) else 0 for x in common_divisors]
print(sum(ans)) A, B = map(int, input().split()) A map(int, input().split()) map int input().split() ().split () input split B import math math def is_prime(x):
    for i in range(2, int(math.sqrt(x))+1):
        if x % i == 0:
            return False

    return True is_prime for i in range(2, int(math.sqrt(x))+1):
        if x % i == 0:
            return False

     i range(2, int(math.sqrt(x))+1) range 2 int(math.sqrt(x))+1 int(math.sqrt(x)) int math.sqrt(x) math.sqrt math sqrt x 1 if x % i == 0:
            return False

     x % i == 0 x % i x i 0 return False False return True True x x def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1

    return lower_divisors + upper_divisors[::-1] make_divisors lower_divisors , upper_divisors = [], [] lower_divisors [] upper_divisors [] i = 1 i 1 while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1

     i*i <= n i*i i i n if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
         n % i == 0 n % i n i 0 lower_divisors.append(i) lower_divisors.append lower_divisors append i if i != n // i:
                upper_divisors.append(n//i)
         i != n // i i n // i n i upper_divisors.append(n//i) upper_divisors.append upper_divisors append n//i n i i += 1 i 1 return lower_divisors + upper_divisors[::-1] lower_divisors + upper_divisors[::-1] lower_divisors upper_divisors[::-1] upper_divisors ::-1 -1 n n def gcd(a, b):

    if a == 0:
        return b
    else:
        return gcd(b%a, a) gcd if a == 0:
        return b
    else:
        return gcd(b%a, a) a == 0 a 0 return b b return gcd(b%a, a) gcd(b%a, a) gcd b%a b a a a a b b da = make_divisors(A) da make_divisors(A) make_divisors A common_divisors = [] common_divisors [] for d in da:
    if B % d == 0:
        common_divisors.append(d) d da if B % d == 0:
        common_divisors.append(d) B % d == 0 B % d B d 0 common_divisors.append(d) common_divisors.append common_divisors append d 1 if is_prime(x) else 0 for x in common_divisors for x in common_divisors x common_divisors for x in common_divisors 1 if is_prime(x) else 0 is_prime(x) is_prime x 1 0 ans = [1 if is_prime(x) else 0 for x in common_divisors] ans [1 if is_prime(x) else 0 for x in common_divisors] print(sum(ans)) print sum(ans) sum ans common_divisors = [] [] common_divisors A, B = map(int, input().split()) map(int, input().split()) A da = make_divisors(A) make_divisors(A) da ans = [1 if is_prime(x) else 0 for x in common_divisors] [1 if is_prime(x) else 0 for x in common_divisors] ans def is_prime(x):
    for i in range(2, int(math.sqrt(x))+1):
        if x % i == 0:
            return False

    return True def is_prime(x):
    for i in range(2, int(math.sqrt(x))+1):
        if x % i == 0:
            return False

    return True is_prime def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1

    return lower_divisors + upper_divisors[::-1] def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1

    return lower_divisors + upper_divisors[::-1] make_divisors def gcd(a, b):

    if a == 0:
        return b
    else:
        return gcd(b%a, a) def gcd(a, b):

    if a == 0:
        return b
    else:
        return gcd(b%a, a) gcd B = map(int, input().split()) map(int, input().split()) B
A, B = map(int, input().split())

import math

def is_prime(x):
    for i in range(2, int(math.sqrt(x))+1):
        if x % i == 0:
            return False

    return True


def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1

    return lower_divisors + upper_divisors[::-1]


def gcd(a, b):

    if a == 0:
        return b
    else:
        return gcd(b%a, a)


da = make_divisors(A)
common_divisors = []

for d in da:
    if B % d == 0:
        common_divisors.append(d)

ans = [1 if is_prime(x) else 0 for x in common_divisors]
print(sum(ans))
