def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a
A, B = map(int, input().split())
C, D = prime_factorize(A), prime_factorize(B)
C.append(1)
D.append(1)
C = set(C)
D = set(D)
print(len(C & D)) def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a prime_factorize a = [] a [] while n % 2 == 0:
        a.append(2)
        n //= 2
     n % 2 == 0 n % 2 n 2 0 a.append(2) a.append a append 2 n //= 2 n 2 f = 3 f 3 while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
     f * f <= n f * f f f n if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
     n % f == 0 n % f n f 0 a.append(f) a.append a append f n //= f n f f += 2 f 2 if n != 1:
        a.append(n)
     n != 1 n 1 a.append(n) a.append a append n return a a n n A, B = map(int, input().split()) A map(int, input().split()) map int input().split() ().split () input split B C, D = prime_factorize(A), prime_factorize(B) C prime_factorize(A) prime_factorize A D prime_factorize(B) prime_factorize B C.append(1) C.append C append 1 D.append(1) D.append D append 1 C = set(C) C set(C) set C D = set(D) D set(D) set D print(len(C & D)) print len(C & D) len C & D C D A, B = map(int, input().split()) map(int, input().split()) A def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a prime_factorize C, D = prime_factorize(A), prime_factorize(B) prime_factorize(A) C B = map(int, input().split()) map(int, input().split()) B D = prime_factorize(A), prime_factorize(B) prime_factorize(B) D D = set(D) set(D) D C = set(C) set(C) C
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a
A, B = map(int, input().split())
C, D = prime_factorize(A), prime_factorize(B)
C.append(1)
D.append(1)
C = set(C)
D = set(D)
print(len(C & D))