A, B = map(int, input().split())


def prime_numbers(N):
    n = N
    res = set()
    for i in range(2, n):
        if i * i >= n: break
        if N % i != 0: continue
        while N % i == 0:
            N //= i
        res.add(i)
    res.add(N)
    res.add(1)
    return res


a = prime_numbers(A)
b = prime_numbers(B)
#print(a, b)
#print(a.intersection(b))
ans = len(a.intersection(b))
print(ans) A, B = map(int, input().split()) A map(int, input().split()) map int input().split() ().split () input split B def prime_numbers(N):
    n = N
    res = set()
    for i in range(2, n):
        if i * i >= n: break
        if N % i != 0: continue
        while N % i == 0:
            N //= i
        res.add(i)
    res.add(N)
    res.add(1)
    return res prime_numbers n = N n N res = set() res set() set for i in range(2, n):
        if i * i >= n: break
        if N % i != 0: continue
        while N % i == 0:
            N //= i
        res.add(i)
     i range(2, n) range 2 n if i * i >= n: break
         i * i >= n i * i i i n if N % i != 0: continue
         N % i != 0 N % i N i 0 while N % i == 0:
            N //= i
         N % i == 0 N % i N i 0 N //= i N i res.add(i) res.add res add i res.add(N) res.add res add N res.add(1) res.add res add 1 return res res N N a = prime_numbers(A) a prime_numbers(A) prime_numbers A b = prime_numbers(B) b prime_numbers(B) prime_numbers B ans = len(a.intersection(b)) ans len(a.intersection(b)) len a.intersection(b) a.intersection a intersection b print(ans) print ans B = map(int, input().split()) map(int, input().split()) B b = prime_numbers(B) prime_numbers(B) b def prime_numbers(N):
    n = N
    res = set()
    for i in range(2, n):
        if i * i >= n: break
        if N % i != 0: continue
        while N % i == 0:
            N //= i
        res.add(i)
    res.add(N)
    res.add(1)
    return res def prime_numbers(N):
    n = N
    res = set()
    for i in range(2, n):
        if i * i >= n: break
        if N % i != 0: continue
        while N % i == 0:
            N //= i
        res.add(i)
    res.add(N)
    res.add(1)
    return res prime_numbers a = prime_numbers(A) prime_numbers(A) a A, B = map(int, input().split()) map(int, input().split()) A ans = len(a.intersection(b)) len(a.intersection(b)) ans
A, B = map(int, input().split())


def prime_numbers(N):
    n = N
    res = set()
    for i in range(2, n):
        if i * i >= n: break
        if N % i != 0: continue
        while N % i == 0:
            N //= i
        res.add(i)
    res.add(N)
    res.add(1)
    return res


a = prime_numbers(A)
b = prime_numbers(B)
#print(a, b)
#print(a.intersection(b))
ans = len(a.intersection(b))
print(ans)
