from functools import lru_cache


@lru_cache(maxsize=None)
def prime_factorization(n):
    """
    nを素因数分解して素因数のリストを返却する
    """
    primes = []
    while n % 2 == 0:
        primes.append(2)
        n //= 2
    i = 3
    while i ** 2 <= n:
        while n % i == 0:
            primes.append(i)
            n //= i
        i += 2
    if n != 1:
        primes.append(n)
    return primes


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

a_primes = set(prime_factorization(A))
b_primes = set(prime_factorization(B))

print(len(a_primes & b_primes) + 1) from functools import lru_cache def prime_factorization(n):
    """
    nを素因数分解して素因数のリストを返却する
    """
    primes = []
    while n % 2 == 0:
        primes.append(2)
        n //= 2
    i = 3
    while i ** 2 <= n:
        while n % i == 0:
            primes.append(i)
            n //= i
        i += 2
    if n != 1:
        primes.append(n)
    return primes prime_factorization """
    nを素因数分解して素因数のリストを返却する
    """ primes = [] primes [] while n % 2 == 0:
        primes.append(2)
        n //= 2
     n % 2 == 0 n % 2 n 2 0 primes.append(2) primes.append primes append 2 n //= 2 n 2 i = 3 i 3 while i ** 2 <= n:
        while n % i == 0:
            primes.append(i)
            n //= i
        i += 2
     i ** 2 <= n i ** 2 i 2 n while n % i == 0:
            primes.append(i)
            n //= i
         n % i == 0 n % i n i 0 primes.append(i) primes.append primes append i n //= i n i i += 2 i 2 if n != 1:
        primes.append(n)
     n != 1 n 1 primes.append(n) primes.append primes append n return primes primes n n @lru_cache(maxsize=None) prime_factorization maxsize=None @lru_cache(maxsize=None) lru_cache maxsize=None maxsize None prime_factorization A, B = map(int, input().split(' ')) A map(int, input().split(' ')) map int input().split(' ') ().split () input split ' ' B a_primes = set(prime_factorization(A)) a_primes set(prime_factorization(A)) set prime_factorization(A) prime_factorization A b_primes = set(prime_factorization(B)) b_primes set(prime_factorization(B)) set prime_factorization(B) prime_factorization B print(len(a_primes & b_primes) + 1) print len(a_primes & b_primes) + 1 len(a_primes & b_primes) len a_primes & b_primes a_primes b_primes 1 B = map(int, input().split(' ')) map(int, input().split(' ')) B A, B = map(int, input().split(' ')) map(int, input().split(' ')) A a_primes = set(prime_factorization(A)) set(prime_factorization(A)) a_primes b_primes = set(prime_factorization(B)) set(prime_factorization(B)) b_primes def prime_factorization(n):
    """
    nを素因数分解して素因数のリストを返却する
    """
    primes = []
    while n % 2 == 0:
        primes.append(2)
        n //= 2
    i = 3
    while i ** 2 <= n:
        while n % i == 0:
            primes.append(i)
            n //= i
        i += 2
    if n != 1:
        primes.append(n)
    return primes def prime_factorization(n):
    """
    nを素因数分解して素因数のリストを返却する
    """
    primes = []
    while n % 2 == 0:
        primes.append(2)
        n //= 2
    i = 3
    while i ** 2 <= n:
        while n % i == 0:
            primes.append(i)
            n //= i
        i += 2
    if n != 1:
        primes.append(n)
    return primes prime_factorization
from functools import lru_cache


@lru_cache(maxsize=None)
def prime_factorization(n):
    """
    nを素因数分解して素因数のリストを返却する
    """
    primes = []
    while n % 2 == 0:
        primes.append(2)
        n //= 2
    i = 3
    while i ** 2 <= n:
        while n % i == 0:
            primes.append(i)
            n //= i
        i += 2
    if n != 1:
        primes.append(n)
    return primes


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

a_primes = set(prime_factorization(A))
b_primes = set(prime_factorization(B))

print(len(a_primes & b_primes) + 1)
