from functools import lru_cache

def main():
    a,b=map(lambda x: set(prime_factorize(int(x))),input().split())
    print(len(a&b)+1)

@lru_cache(maxsize=None)
def primes(n:int) -> list:
    '''n以下の全素数をlistで返す'''
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5) + 1):
        if not is_prime[i]:
            continue
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False
    return [i for i in range(n + 1) if is_prime[i]]

# 素数判定（単純な素数判定なら十分早い。大量にやる場合はX in primesがよさそう）
@lru_cache(maxsize=None)
def is_prime(n: int) -> bool:
    '''引数nが素数であればTrue、そうでなければFalseを返す'''
    if n == 1:
        return False
    elif n == 2:
        return True
    elif n % 2 == 0:
        return False
    
    for i in range(3, int(n**0.5)+1, 2):
        if n % i == 0:
            return False
    return True

# 素因数分解
@lru_cache(maxsize=None)
def prime_factorize(n: int) -> list:
    '''引数nの素因数分解結果のlistを返す。'''
    arr = []
    # 2で割り続け奇数まで還元する
    while n % 2 == 0:
        arr.append(2)
        n //= 2
    # sqrt(n)までの素数で試し割
    for f in primes(int(n**0.5)):
        while n % f == 0:
            arr.append(f)
            n //= f
    if n != 1:
        arr.append(n)
    return arr

#約数リスト
def make_divisors(n: int) -> list:
    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]
        
if __name__ == "__main__":
    main() from functools import lru_cache def main():
    a,b=map(lambda x: set(prime_factorize(int(x))),input().split())
    print(len(a&b)+1) main a,b=map(lambda x: set(prime_factorize(int(x))),input().split()) a map(lambda x: set(prime_factorize(int(x))),input().split()) map lambda x: set(prime_factorize(int(x))) set(prime_factorize(int(x))) set prime_factorize(int(x)) prime_factorize int(x) int x x input().split() ().split () input split b print(len(a&b)+1) print len(a&b)+1 len(a&b) len a&b a b 1 def primes(n:int) -> list:
    '''n以下の全素数をlistで返す'''
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5) + 1):
        if not is_prime[i]:
            continue
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False
    return [i for i in range(n + 1) if is_prime[i]]

# 素数判定（単純な素数判定なら十分早い。大量にやる場合はX in primesがよさそう） primes '''n以下の全素数をlistで返す''' is_prime = [True] * (n + 1) is_prime [True] * (n + 1) [True] True n + 1 n 1 is_prime[0] = False is_prime[0] is_prime 0 False is_prime[1] = False is_prime[1] is_prime 1 False for i in range(2, int(n**0.5) + 1):
        if not is_prime[i]:
            continue
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False
     i range(2, int(n**0.5) + 1) range 2 int(n**0.5) + 1 int(n**0.5) int n**0.5 n 0.5 1 if not is_prime[i]:
            continue
         not is_prime[i] is_prime[i] is_prime i continue for j in range(i * 2, n + 1, i):
            is_prime[j] = False
     j range(i * 2, n + 1, i) range i * 2 i 2 n + 1 n 1 i is_prime[j] = False is_prime[j] is_prime j False i for i in range(n + 1) if is_prime[i] for i in range(n + 1) if is_prime[i] i range(n + 1) range n + 1 n 1 is_prime[i] is_prime i if is_prime[i] i return [i for i in range(n + 1) if is_prime[i]] [i for i in range(n + 1) if is_prime[i]] n:int n @lru_cache(maxsize=None) primes maxsize=None @lru_cache(maxsize=None) lru_cache maxsize=None maxsize None primes def is_prime(n: int) -> bool:
    '''引数nが素数であればTrue、そうでなければFalseを返す'''
    if n == 1:
        return False
    elif n == 2:
        return True
    elif n % 2 == 0:
        return False
    
    for i in range(3, int(n**0.5)+1, 2):
        if n % i == 0:
            return False
    return True

# 素因数分解 is_prime '''引数nが素数であればTrue、そうでなければFalseを返す''' if n == 1:
        return False
    elif n == 2:
        return True
    elif n % 2 == 0:
        return False
    
     n == 1 n 1 return False False elif n == 2:
        return True
     n == 2 n 2 return True True elif n % 2 == 0:
        return False
    
     n % 2 == 0 n % 2 n 2 0 return False False for i in range(3, int(n**0.5)+1, 2):
        if n % i == 0:
            return False
     i range(3, int(n**0.5)+1, 2) range 3 int(n**0.5)+1 int(n**0.5) int n**0.5 n 0.5 1 2 if n % i == 0:
            return False
     n % i == 0 n % i n i 0 return False False return True True n: int n @lru_cache(maxsize=None) is_prime maxsize=None @lru_cache(maxsize=None) lru_cache maxsize=None maxsize None is_prime def prime_factorize(n: int) -> list:
    '''引数nの素因数分解結果のlistを返す。'''
    arr = []
    # 2で割り続け奇数まで還元する
    while n % 2 == 0:
        arr.append(2)
        n //= 2
    # sqrt(n)までの素数で試し割
    for f in primes(int(n**0.5)):
        while n % f == 0:
            arr.append(f)
            n //= f
    if n != 1:
        arr.append(n)
    return arr

#約数リスト prime_factorize '''引数nの素因数分解結果のlistを返す。''' arr = [] arr [] while n % 2 == 0:
        arr.append(2)
        n //= 2
    # sqrt(n)までの素数で試し割
     n % 2 == 0 n % 2 n 2 0 arr.append(2) arr.append arr append 2 n //= 2 n 2 for f in primes(int(n**0.5)):
        while n % f == 0:
            arr.append(f)
            n //= f
     f primes(int(n**0.5)) primes int(n**0.5) int n**0.5 n 0.5 while n % f == 0:
            arr.append(f)
            n //= f
     n % f == 0 n % f n f 0 arr.append(f) arr.append arr append f n //= f n f if n != 1:
        arr.append(n)
     n != 1 n 1 arr.append(n) arr.append arr append n return arr arr n: int n @lru_cache(maxsize=None) prime_factorize maxsize=None @lru_cache(maxsize=None) lru_cache maxsize=None maxsize None prime_factorize def make_divisors(n: int) -> list:
    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: int n if __name__ == "__main__":
    main() __name__ == "__main__" __name__ "__main__" main() main def prime_factorize(n: int) -> list:
    '''引数nの素因数分解結果のlistを返す。'''
    arr = []
    # 2で割り続け奇数まで還元する
    while n % 2 == 0:
        arr.append(2)
        n //= 2
    # sqrt(n)までの素数で試し割
    for f in primes(int(n**0.5)):
        while n % f == 0:
            arr.append(f)
            n //= f
    if n != 1:
        arr.append(n)
    return arr

#約数リスト def prime_factorize(n: int) -> list:
    '''引数nの素因数分解結果のlistを返す。'''
    arr = []
    # 2で割り続け奇数まで還元する
    while n % 2 == 0:
        arr.append(2)
        n //= 2
    # sqrt(n)までの素数で試し割
    for f in primes(int(n**0.5)):
        while n % f == 0:
            arr.append(f)
            n //= f
    if n != 1:
        arr.append(n)
    return arr

#約数リスト prime_factorize def is_prime(n: int) -> bool:
    '''引数nが素数であればTrue、そうでなければFalseを返す'''
    if n == 1:
        return False
    elif n == 2:
        return True
    elif n % 2 == 0:
        return False
    
    for i in range(3, int(n**0.5)+1, 2):
        if n % i == 0:
            return False
    return True

# 素因数分解 def is_prime(n: int) -> bool:
    '''引数nが素数であればTrue、そうでなければFalseを返す'''
    if n == 1:
        return False
    elif n == 2:
        return True
    elif n % 2 == 0:
        return False
    
    for i in range(3, int(n**0.5)+1, 2):
        if n % i == 0:
            return False
    return True

# 素因数分解 is_prime def make_divisors(n: int) -> list:
    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: int) -> list:
    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 primes(n:int) -> list:
    '''n以下の全素数をlistで返す'''
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5) + 1):
        if not is_prime[i]:
            continue
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False
    return [i for i in range(n + 1) if is_prime[i]]

# 素数判定（単純な素数判定なら十分早い。大量にやる場合はX in primesがよさそう） def primes(n:int) -> list:
    '''n以下の全素数をlistで返す'''
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5) + 1):
        if not is_prime[i]:
            continue
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False
    return [i for i in range(n + 1) if is_prime[i]]

# 素数判定（単純な素数判定なら十分早い。大量にやる場合はX in primesがよさそう） primes def main():
    a,b=map(lambda x: set(prime_factorize(int(x))),input().split())
    print(len(a&b)+1) def main():
    a,b=map(lambda x: set(prime_factorize(int(x))),input().split())
    print(len(a&b)+1) main
from functools import lru_cache

def main():
    a,b=map(lambda x: set(prime_factorize(int(x))),input().split())
    print(len(a&b)+1)

@lru_cache(maxsize=None)
def primes(n:int) -> list:
    '''n以下の全素数をlistで返す'''
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5) + 1):
        if not is_prime[i]:
            continue
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False
    return [i for i in range(n + 1) if is_prime[i]]

# 素数判定（単純な素数判定なら十分早い。大量にやる場合はX in primesがよさそう）
@lru_cache(maxsize=None)
def is_prime(n: int) -> bool:
    '''引数nが素数であればTrue、そうでなければFalseを返す'''
    if n == 1:
        return False
    elif n == 2:
        return True
    elif n % 2 == 0:
        return False
    
    for i in range(3, int(n**0.5)+1, 2):
        if n % i == 0:
            return False
    return True

# 素因数分解
@lru_cache(maxsize=None)
def prime_factorize(n: int) -> list:
    '''引数nの素因数分解結果のlistを返す。'''
    arr = []
    # 2で割り続け奇数まで還元する
    while n % 2 == 0:
        arr.append(2)
        n //= 2
    # sqrt(n)までの素数で試し割
    for f in primes(int(n**0.5)):
        while n % f == 0:
            arr.append(f)
            n //= f
    if n != 1:
        arr.append(n)
    return arr

#約数リスト
def make_divisors(n: int) -> list:
    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]
        
if __name__ == "__main__":
    main()