def slove():

    import sys

    import fractions

    input = sys.stdin.readline

    a, b = list(map(int, input().rstrip('\n').split()))

    gcd = fractions.gcd(a, b)

    cnt = 1

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

        if gcd % i == 0:

            cnt += 1

            while True:

                if gcd % i == 0:

                    gcd //= i

                else:

                    break

    if gcd != 1:

        cnt += 1

    print(cnt)





if __name__ == '__main__':

    slove()

def slove():

    import sys

    import fractions

    input = sys.stdin.readline

    a, b = list(map(int, input().rstrip('\n').split()))

    gcd = fractions.gcd(a, b)

    cnt = 1

    s = 2

    e = int(gcd ** 0.5) + 1

    d = True

    while True:

        if d:

            d = False

            for i in range(s, e):

                if gcd % i == 0:

                    d = True

                    cnt += 1

                    while True:

                        if gcd % i == 0:

                            gcd //= i

                        else:

                            break

                    s = i + 1

                    e = int(gcd ** 0.5) + 1

                    break

        else:

            break

    if gcd != 1:

        cnt += 1

    print(cnt)





if __name__ == '__main__':

    slove()

def slove():
    import sys
    import fractions

    input = sys.stdin.readline
    a, b = list(map(int, input().rstrip("\n").split()))
    gcd = fractions.gcd(a, b)
    cnt = 1
    for i in range(2, int(gcd**0.5) + 1):
        if gcd % i == 0:
            cnt += 1
            while True:
                if gcd % i == 0:
                    gcd //= i
                else:
                    break
    if gcd != 1:
        cnt += 1
    print(cnt)


if __name__ == "__main__":
    slove()

def slove():
    import sys
    import fractions

    input = sys.stdin.readline
    a, b = list(map(int, input().rstrip("\n").split()))
    gcd = fractions.gcd(a, b)
    cnt = 1
    s = 2
    e = int(gcd**0.5) + 1
    d = True
    while True:
        if d:
            d = False
            for i in range(s, e):
                if gcd % i == 0:
                    d = True
                    cnt += 1
                    while True:
                        if gcd % i == 0:
                            gcd //= i
                        else:
                            break
                    s = i + 1
                    e = int(gcd**0.5) + 1
                    break
        else:
            break
    if gcd != 1:
        cnt += 1
    print(cnt)


if __name__ == "__main__":
    slove()

-    for i in range(2, int(gcd**0.5) + 1): -        if gcd % i == 0: -            cnt += 1 -            while True: +    s = 2 +    e = int(gcd**0.5) + 1 +    d = True +    while True: +        if d: +            d = False +            for i in range(s, e): -                    gcd //= i -                else: +                    d = True +                    cnt += 1 +                    while True: +                        if gcd % i == 0: +                            gcd //= i +                        else: +                            break +                    s = i + 1 +                    e = int(gcd**0.5) + 1 +        else: +            break