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

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

a,b = map(int,input().split())
A = prime_factorize(a)
B = prime_factorize(b)
G = []
for i in set(A):
    if i in set(B):
        G.append(i)
print(len(set(G)) + 1)