def main():

    N, M = (int(i) for i in input().split())



    def enum_divisors(n):

        # 約数列挙

        divs = set()

        for i in range(1, n+1):

            if i*i > n:

                break

            if n % i == 0:

                divs.add(i)

                if n//i != i:

                    # i が平方数でない

                    divs.add(n//i)

        return divs



    divs = enum_divisors(N) & enum_divisors(M)

    ans = 1

    v = 1

    from math import gcd

    for s in sorted(divs):

        if s == 1:

            continue

        if gcd(v, s) == 1:

            v *= s

            ans += 1

    print(ans)





if __name__ == '__main__':

    main()

def main():

    N, M = (int(i) for i in input().split())



    def prime_factorize(n):

        res = []

        for i in range(2, n+1):

            if i*i > n:

                break

            if n % i != 0:

                continue

            ex = 0

            while n % i == 0:

                ex += 1

                n //= i

            res.append((i, ex))

        if n != 1:

            res.append((n, 1))

        return res



    from math import gcd

    g = gcd(N, M)

    pf = prime_factorize(g)



    ans = 1 + len(pf)



    print(ans)





if __name__ == '__main__':

    main()

def main():
    N, M = (int(i) for i in input().split())

    def enum_divisors(n):
        # 約数列挙
        divs = set()
        for i in range(1, n + 1):
            if i * i > n:
                break
            if n % i == 0:
                divs.add(i)
                if n // i != i:
                    # i が平方数でない
                    divs.add(n // i)
        return divs

    divs = enum_divisors(N) & enum_divisors(M)
    ans = 1
    v = 1
    from math import gcd

    for s in sorted(divs):
        if s == 1:
            continue
        if gcd(v, s) == 1:
            v *= s
            ans += 1
    print(ans)


if __name__ == "__main__":
    main()

def main():
    N, M = (int(i) for i in input().split())

    def prime_factorize(n):
        res = []
        for i in range(2, n + 1):
            if i * i > n:
                break
            if n % i != 0:
                continue
            ex = 0
            while n % i == 0:
                ex += 1
                n //= i
            res.append((i, ex))
        if n != 1:
            res.append((n, 1))
        return res

    from math import gcd

    g = gcd(N, M)
    pf = prime_factorize(g)
    ans = 1 + len(pf)
    print(ans)


if __name__ == "__main__":
    main()

-    def enum_divisors(n): -        # 約数列挙 -        divs = set() -        for i in range(1, n + 1): +    def prime_factorize(n): +        res = [] +        for i in range(2, n + 1): -            if n % i == 0: -                divs.add(i) -                if n // i != i: -                    # i が平方数でない -                    divs.add(n // i) -        return divs +            if n % i != 0: +                continue +            ex = 0 +            while n % i == 0: +                ex += 1 +                n //= i +            res.append((i, ex)) +        if n != 1: +            res.append((n, 1)) +        return res -    divs = enum_divisors(N) & enum_divisors(M) -    ans = 1 -    v = 1 -    for s in sorted(divs): -        if s == 1: -            continue -        if gcd(v, s) == 1: -            v *= s -            ans += 1 +    g = gcd(N, M) +    pf = prime_factorize(g) +    ans = 1 + len(pf)