a,b=map(int, input().split())

if a==1 or b==1:
    print(1)
    exit()

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_prime=prime_factorize(a)
b_prime=prime_factorize(b)

a_prime=set(a_prime)
b_prime=set(b_prime)

ans=0
for i in a_prime:
    if i in b_prime:
        ans+=1

print(ans+1) a,b=map(int, input().split()) a map(int, input().split()) map int input().split() ().split () input split b if a==1 or b==1:
    print(1)
    exit() a==1 or b==1 a==1 a 1 b==1 b 1 print(1) print 1 exit() exit 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_prime=prime_factorize(a) a_prime prime_factorize(a) prime_factorize a b_prime=prime_factorize(b) b_prime prime_factorize(b) prime_factorize b a_prime=set(a_prime) a_prime set(a_prime) set a_prime b_prime=set(b_prime) b_prime set(b_prime) set b_prime ans=0 ans 0 for i in a_prime:
    if i in b_prime:
        ans+=1 i a_prime if i in b_prime:
        ans+=1 i in b_prime i b_prime ans+=1 ans 1 print(ans+1) print ans+1 ans 1 b_prime=set(b_prime) set(b_prime) b_prime b_prime=prime_factorize(b) prime_factorize(b) b_prime ans=0 0 ans a_prime=set(a_prime) set(a_prime) a_prime ans+=1 1 ans 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 a_prime=prime_factorize(a) prime_factorize(a) a_prime b=map(int, input().split()) map(int, input().split()) b
a,b=map(int, input().split())

if a==1 or b==1:
    print(1)
    exit()

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_prime=prime_factorize(a)
b_prime=prime_factorize(b)

a_prime=set(a_prime)
b_prime=set(b_prime)

ans=0
for i in a_prime:
    if i in b_prime:
        ans+=1

print(ans+1)