import fractions
import sys
sys.setrecursionlimit(10**9)


INF=10**20
def prime_factorize(n):
    P = []
    P_set = set()
    while n % 2 == 0:
        P.append(2)
        P_set.add(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            P.append(f)
            P_set.add(f)
            n //= f
        else:
            f += 2
    if n != 1:
        P.append(n)
        P_set.add(n)

    P_count = {p:0 for p in P_set}
    for p in P: P_count[p] += 1

    return P_count


def solve(A: int, B: int):
    gcd = fractions.gcd(A,B)
    P = prime_factorize(gcd).keys()
    print(len(list(P))+1)
    return

def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    solve(A, B)



if __name__ == "__main__":
    main() import fractions fractions import sys sys sys.setrecursionlimit(10**9) sys.setrecursionlimit sys setrecursionlimit 10**9 10 9 INF=10**20 INF 10**20 10 20 def prime_factorize(n):
    P = []
    P_set = set()
    while n % 2 == 0:
        P.append(2)
        P_set.add(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            P.append(f)
            P_set.add(f)
            n //= f
        else:
            f += 2
    if n != 1:
        P.append(n)
        P_set.add(n)

    P_count = {p:0 for p in P_set}
    for p in P: P_count[p] += 1

    return P_count prime_factorize P = [] P [] P_set = set() P_set set() set while n % 2 == 0:
        P.append(2)
        P_set.add(2)
        n //= 2
     n % 2 == 0 n % 2 n 2 0 P.append(2) P.append P append 2 P_set.add(2) P_set.add P_set add 2 n //= 2 n 2 f = 3 f 3 while f * f <= n:
        if n % f == 0:
            P.append(f)
            P_set.add(f)
            n //= f
        else:
            f += 2
     f * f <= n f * f f f n if n % f == 0:
            P.append(f)
            P_set.add(f)
            n //= f
        else:
            f += 2
     n % f == 0 n % f n f 0 P.append(f) P.append P append f P_set.add(f) P_set.add P_set add f n //= f n f f += 2 f 2 if n != 1:
        P.append(n)
        P_set.add(n)

     n != 1 n 1 P.append(n) P.append P append n P_set.add(n) P_set.add P_set add n p:0 for p in P_set for p in P_set p P_set for p in P_set p 0 P_count = {p:0 for p in P_set} P_count {p:0 for p in P_set} for p in P: P_count[p] += 1

     p P return P_count P_count n n def solve(A: int, B: int):
    gcd = fractions.gcd(A,B)
    P = prime_factorize(gcd).keys()
    print(len(list(P))+1)
    return solve gcd = fractions.gcd(A,B) gcd fractions.gcd(A,B) fractions.gcd fractions gcd A B P = prime_factorize(gcd).keys() P prime_factorize(gcd).keys() (gcd).keys (gcd) prime_factorize gcd keys print(len(list(P))+1) print len(list(P))+1 len(list(P)) len list(P) list P 1 return A: int A B: int B def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    solve(A, B) main def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
     iterate_tokens for line in sys.stdin:
            for word in line.split():
                yield word
     line sys.stdin sys stdin for word in line.split():
                yield word
     word line.split() line.split line split yield word word tokens = iterate_tokens() tokens iterate_tokens() iterate_tokens A = int(next(tokens)) A int(next(tokens)) int next(tokens) next tokens B = int(next(tokens)) B int(next(tokens)) int next(tokens) next tokens solve(A, B) solve A B if __name__ == "__main__":
    main() __name__ == "__main__" __name__ "__main__" main() main def prime_factorize(n):
    P = []
    P_set = set()
    while n % 2 == 0:
        P.append(2)
        P_set.add(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            P.append(f)
            P_set.add(f)
            n //= f
        else:
            f += 2
    if n != 1:
        P.append(n)
        P_set.add(n)

    P_count = {p:0 for p in P_set}
    for p in P: P_count[p] += 1

    return P_count def prime_factorize(n):
    P = []
    P_set = set()
    while n % 2 == 0:
        P.append(2)
        P_set.add(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            P.append(f)
            P_set.add(f)
            n //= f
        else:
            f += 2
    if n != 1:
        P.append(n)
        P_set.add(n)

    P_count = {p:0 for p in P_set}
    for p in P: P_count[p] += 1

    return P_count prime_factorize def solve(A: int, B: int):
    gcd = fractions.gcd(A,B)
    P = prime_factorize(gcd).keys()
    print(len(list(P))+1)
    return def solve(A: int, B: int):
    gcd = fractions.gcd(A,B)
    P = prime_factorize(gcd).keys()
    print(len(list(P))+1)
    return solve def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    solve(A, B) def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    solve(A, B) main INF=10**20 10**20 INF
import fractions
import sys
sys.setrecursionlimit(10**9)


INF=10**20
def prime_factorize(n):
    P = []
    P_set = set()
    while n % 2 == 0:
        P.append(2)
        P_set.add(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            P.append(f)
            P_set.add(f)
            n //= f
        else:
            f += 2
    if n != 1:
        P.append(n)
        P_set.add(n)

    P_count = {p:0 for p in P_set}
    for p in P: P_count[p] += 1

    return P_count


def solve(A: int, B: int):
    gcd = fractions.gcd(A,B)
    P = prime_factorize(gcd).keys()
    print(len(list(P))+1)
    return

def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    solve(A, B)



if __name__ == "__main__":
    main()
