n, m = map(int, input().split(" "))


def divisor(n):
    i = 1
    table = []
    while i * i <= n:
        if n % i == 0:
            table.append(i)
            table.append(n // i)
        i += 1
    table = sorted(list(set(table)))
    return table


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


s = set(divisor(n)).intersection(set(divisor(m)))

ans = 1
for ss in s:
    if len(prime_factorize(ss)) == 1:
        ans += 1

print(ans) n, m = map(int, input().split(" ")) n map(int, input().split(" ")) map int input().split(" ") ().split () input split " " m def divisor(n):
    i = 1
    table = []
    while i * i <= n:
        if n % i == 0:
            table.append(i)
            table.append(n // i)
        i += 1
    table = sorted(list(set(table)))
    return table divisor i = 1 i 1 table = [] table [] while i * i <= n:
        if n % i == 0:
            table.append(i)
            table.append(n // i)
        i += 1
     i * i <= n i * i i i n if n % i == 0:
            table.append(i)
            table.append(n // i)
         n % i == 0 n % i n i 0 table.append(i) table.append table append i table.append(n // i) table.append table append n // i n i i += 1 i 1 table = sorted(list(set(table))) table sorted(list(set(table))) sorted list(set(table)) list set(table) set table return table table n n 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 s = set(divisor(n)).intersection(set(divisor(m))) s set(divisor(n)).intersection(set(divisor(m))) (divisor(n)).intersection (divisor(n)) set divisor(n) divisor n intersection set(divisor(m)) set divisor(m) divisor m ans = 1 ans 1 for ss in s:
    if len(prime_factorize(ss)) == 1:
        ans += 1 ss s if len(prime_factorize(ss)) == 1:
        ans += 1 len(prime_factorize(ss)) == 1 len(prime_factorize(ss)) len prime_factorize(ss) prime_factorize ss 1 ans += 1 ans 1 print(ans) print ans s = set(divisor(n)).intersection(set(divisor(m))) set(divisor(n)).intersection(set(divisor(m))) s m = map(int, input().split(" ")) map(int, input().split(" ")) m n, m = map(int, input().split(" ")) map(int, input().split(" ")) n def divisor(n):
    i = 1
    table = []
    while i * i <= n:
        if n % i == 0:
            table.append(i)
            table.append(n // i)
        i += 1
    table = sorted(list(set(table)))
    return table def divisor(n):
    i = 1
    table = []
    while i * i <= n:
        if n % i == 0:
            table.append(i)
            table.append(n // i)
        i += 1
    table = sorted(list(set(table)))
    return table divisor ans += 1 1 ans 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 ans = 1 1 ans
n, m = map(int, input().split(" "))


def divisor(n):
    i = 1
    table = []
    while i * i <= n:
        if n % i == 0:
            table.append(i)
            table.append(n // i)
        i += 1
    table = sorted(list(set(table)))
    return table


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


s = set(divisor(n)).intersection(set(divisor(m)))

ans = 1
for ss in s:
    if len(prime_factorize(ss)) == 1:
        ans += 1

print(ans)