from functools import lru_cache


@lru_cache(maxsize=None)
def get_dividers(n):
    """
    正の整数 n の約数を取得する
    """

    dividers = {i for i in range(1, int(n ** 0.5) + 1) if n % i == 0}
    return dividers | {n // d for d in dividers}


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

a_dividers = get_dividers(A)
b_dividers = get_dividers(B)
common_dividers = a_dividers & b_dividers
ans = []

for cd in sorted(common_dividers):
    dividers = get_dividers(cd) - {1}
    for d in ans:
        if d & dividers:
            break
    else:
        ans.append(dividers)

print(len(ans)) from functools import lru_cache def get_dividers(n):
    """
    正の整数 n の約数を取得する
    """

    dividers = {i for i in range(1, int(n ** 0.5) + 1) if n % i == 0}
    return dividers | {n // d for d in dividers} get_dividers """
    正の整数 n の約数を取得する
    """ i for i in range(1, int(n ** 0.5) + 1) if n % i == 0 for i in range(1, int(n ** 0.5) + 1) if n % i == 0 i range(1, int(n ** 0.5) + 1) range 1 int(n ** 0.5) + 1 int(n ** 0.5) int n ** 0.5 n 0.5 1 n % i == 0 n % i n i 0 if n % i == 0 i dividers = {i for i in range(1, int(n ** 0.5) + 1) if n % i == 0} dividers n // d for d in dividers for d in dividers d dividers for d in dividers n // d n d return dividers | {n // d for d in dividers} dividers | {n // d for d in dividers} dividers n n @lru_cache(maxsize=None) get_dividers maxsize=None @lru_cache(maxsize=None) lru_cache maxsize=None maxsize None get_dividers A, B = map(int, input().split(' ')) A map(int, input().split(' ')) map int input().split(' ') ().split () input split ' ' B a_dividers = get_dividers(A) a_dividers get_dividers(A) get_dividers A b_dividers = get_dividers(B) b_dividers get_dividers(B) get_dividers B common_dividers = a_dividers & b_dividers common_dividers a_dividers & b_dividers a_dividers b_dividers ans = [] ans [] for cd in sorted(common_dividers):
    dividers = get_dividers(cd) - {1}
    for d in ans:
        if d & dividers:
            break
    else:
        ans.append(dividers) cd sorted(common_dividers) sorted common_dividers dividers = get_dividers(cd) - {1} dividers get_dividers(cd) - {1} get_dividers(cd) get_dividers cd {1} for d in ans:
        if d & dividers:
            break
    else:
        ans.append(dividers) d ans if d & dividers:
            break
     d & dividers d dividers break ans.append(dividers) ans.append ans append dividers print(len(ans)) print len(ans) len ans common_dividers = a_dividers & b_dividers a_dividers & b_dividers common_dividers def get_dividers(n):
    """
    正の整数 n の約数を取得する
    """

    dividers = {i for i in range(1, int(n ** 0.5) + 1) if n % i == 0}
    return dividers | {n // d for d in dividers} def get_dividers(n):
    """
    正の整数 n の約数を取得する
    """

    dividers = {i for i in range(1, int(n ** 0.5) + 1) if n % i == 0}
    return dividers | {n // d for d in dividers} get_dividers A, B = map(int, input().split(' ')) map(int, input().split(' ')) A dividers = get_dividers(cd) - {1} get_dividers(cd) - {1} dividers b_dividers = get_dividers(B) get_dividers(B) b_dividers B = map(int, input().split(' ')) map(int, input().split(' ')) B ans = [] [] ans a_dividers = get_dividers(A) get_dividers(A) a_dividers
from functools import lru_cache


@lru_cache(maxsize=None)
def get_dividers(n):
    """
    正の整数 n の約数を取得する
    """

    dividers = {i for i in range(1, int(n ** 0.5) + 1) if n % i == 0}
    return dividers | {n // d for d in dividers}


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

a_dividers = get_dividers(A)
b_dividers = get_dividers(B)
common_dividers = a_dividers & b_dividers
ans = []

for cd in sorted(common_dividers):
    dividers = get_dividers(cd) - {1}
    for d in ans:
        if d & dividers:
            break
    else:
        ans.append(dividers)

print(len(ans))
