# ABC142D - Disjoint Set of Common Divisors

def divisors(n: int) -> set:

    div = set()

    for i in range(1, int(n ** 0.5) + 1):

        if n % i == 0:

            div.add(i), div.add(n // i)

    return div





def main():

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

    divs = sorted(divisors(A) & divisors(B))

    divs.pop(0)

    groups = set()

    for i in divs:

        if all(i % x for x in groups):

            groups.add(i)

    ans = len(groups) + 1

    print(ans)





if __name__ == "__main__":

    main()
# ABC142D - Disjoint Set of Common Divisors

from fractions import gcd

# from math import gcd





def divisors(n: int) -> set:

    div = set()

    for i in range(1, int(n ** 0.5) + 1):

        if n % i == 0:

            div.add(i), div.add(n // i)

    return sorted(div)





def main():

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

    divs = divisors(gcd(A, B))

    divs.pop(0)  # 1 divides all numbers -> pop

    groups = set()

    for i in divs:

        if all(i % x for x in groups):

            groups.add(i)  # coprime to all numbers in "groups"

    ans = len(groups) + 1

    print(ans)





if __name__ == "__main__":

    main()
# ABC142D - Disjoint Set of Common Divisors
def divisors(n: int) -> set:
    div = set()
    for i in range(1, int(n**0.5) + 1):
        if n % i == 0:
            div.add(i), div.add(n // i)
    return div


def main():
    A, B = list(map(int, input().split()))
    divs = sorted(divisors(A) & divisors(B))
    divs.pop(0)
    groups = set()
    for i in divs:
        if all(i % x for x in groups):
            groups.add(i)
    ans = len(groups) + 1
    print(ans)


if __name__ == "__main__":
    main()

# ABC142D - Disjoint Set of Common Divisors
from fractions import gcd

# from math import gcd
def divisors(n: int) -> set:
    div = set()
    for i in range(1, int(n**0.5) + 1):
        if n % i == 0:
            div.add(i), div.add(n // i)
    return sorted(div)


def main():
    A, B = list(map(int, input().split()))
    divs = divisors(gcd(A, B))
    divs.pop(0)  # 1 divides all numbers -> pop
    groups = set()
    for i in divs:
        if all(i % x for x in groups):
            groups.add(i)  # coprime to all numbers in "groups"
    ans = len(groups) + 1
    print(ans)


if __name__ == "__main__":
    main()

+from fractions import gcd + +# from math import gcd -    return div +    return sorted(div) -    divs = sorted(divisors(A) & divisors(B)) -    divs.pop(0) +    divs = divisors(gcd(A, B)) +    divs.pop(0)  # 1 divides all numbers -> pop -            groups.add(i) +            groups.add(i)  # coprime to all numbers in "groups"