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

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors

def is_prime(n):
    if n <= 1: return False
    for i in range(2, int(n**0.5)+1):
        if n%i == 0: return False
    return True

ab = list(set(make_divisors(a)) & set(make_divisors(b)))

ans = 1
for i in ab[1:]:
    if is_prime(i): ans += 1
print(ans) a,b = map(int, input().split()) a map(int, input().split()) map int input().split() ().split () input split b def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors make_divisors divisors = [] divisors [] for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

     i range(1, int(n**0.5)+1) range 1 int(n**0.5)+1 int(n**0.5) int n**0.5 n 0.5 1 if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

     n % i == 0 n % i n i 0 divisors.append(i) divisors.append divisors append i if i != n // i:
                divisors.append(n//i)

     i != n // i i n // i n i divisors.append(n//i) divisors.append divisors append n//i n i divisors.sort() divisors.sort divisors sort return divisors divisors n n def is_prime(n):
    if n <= 1: return False
    for i in range(2, int(n**0.5)+1):
        if n%i == 0: return False
    return True is_prime if n <= 1: return False
     n <= 1 n 1 for i in range(2, int(n**0.5)+1):
        if n%i == 0: return False
     i range(2, int(n**0.5)+1) range 2 int(n**0.5)+1 int(n**0.5) int n**0.5 n 0.5 1 if n%i == 0: return False
     n%i == 0 n%i n i 0 return True True n n ab = list(set(make_divisors(a)) & set(make_divisors(b))) ab list(set(make_divisors(a)) & set(make_divisors(b))) list set(make_divisors(a)) & set(make_divisors(b)) set(make_divisors(a)) set make_divisors(a) make_divisors a set(make_divisors(b)) set make_divisors(b) make_divisors b ans = 1 ans 1 for i in ab[1:]:
    if is_prime(i): ans += 1 i ab[1:] ab 1: 1 if is_prime(i): ans  is_prime(i) is_prime i print(ans) print ans ans = 1 1 ans def is_prime(n):
    if n <= 1: return False
    for i in range(2, int(n**0.5)+1):
        if n%i == 0: return False
    return True def is_prime(n):
    if n <= 1: return False
    for i in range(2, int(n**0.5)+1):
        if n%i == 0: return False
    return True is_prime ab = list(set(make_divisors(a)) & set(make_divisors(b))) list(set(make_divisors(a)) & set(make_divisors(b))) ab b = map(int, input().split()) map(int, input().split()) b def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors make_divisors a,b = map(int, input().split()) map(int, input().split()) a
a,b = map(int, input().split())

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors

def is_prime(n):
    if n <= 1: return False
    for i in range(2, int(n**0.5)+1):
        if n%i == 0: return False
    return True

ab = list(set(make_divisors(a)) & set(make_divisors(b)))

ans = 1
for i in ab[1:]:
    if is_prime(i): ans += 1
print(ans)