def division(n):
    if n < 2:
        return [1]

    prime_factors = [1]

    for i in range(2,int(n**0.5)+1):
        while n % i == 0:
            prime_factors.append(i)
            n //= i
    if n > 1:
        prime_factors.append(n)

    return prime_factors

a,b = map(int,input().split())
da = set(division(a))
db = set(division(b))
cnt = 0
for i in da:
    if i in db:
        cnt += 1
print(cnt) def division(n):
    if n < 2:
        return [1]

    prime_factors = [1]

    for i in range(2,int(n**0.5)+1):
        while n % i == 0:
            prime_factors.append(i)
            n //= i
    if n > 1:
        prime_factors.append(n)

    return prime_factors division if n < 2:
        return [1]

     n < 2 n 2 return [1] [1] 1 prime_factors = [1] prime_factors [1] 1 for i in range(2,int(n**0.5)+1):
        while n % i == 0:
            prime_factors.append(i)
            n //= i
     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 while n % i == 0:
            prime_factors.append(i)
            n //= i
     n % i == 0 n % i n i 0 prime_factors.append(i) prime_factors.append prime_factors append i n //= i n i if n > 1:
        prime_factors.append(n)

     n > 1 n 1 prime_factors.append(n) prime_factors.append prime_factors append n return prime_factors prime_factors n n a,b = map(int,input().split()) a map(int,input().split()) map int input().split() ().split () input split b da = set(division(a)) da set(division(a)) set division(a) division a db = set(division(b)) db set(division(b)) set division(b) division b cnt = 0 cnt 0 for i in da:
    if i in db:
        cnt += 1 i da if i in db:
        cnt += 1 i in db i db cnt += 1 cnt 1 print(cnt) print cnt cnt += 1 1 cnt db = set(division(b)) set(division(b)) db a,b = map(int,input().split()) map(int,input().split()) a da = set(division(a)) set(division(a)) da def division(n):
    if n < 2:
        return [1]

    prime_factors = [1]

    for i in range(2,int(n**0.5)+1):
        while n % i == 0:
            prime_factors.append(i)
            n //= i
    if n > 1:
        prime_factors.append(n)

    return prime_factors def division(n):
    if n < 2:
        return [1]

    prime_factors = [1]

    for i in range(2,int(n**0.5)+1):
        while n % i == 0:
            prime_factors.append(i)
            n //= i
    if n > 1:
        prime_factors.append(n)

    return prime_factors division b = map(int,input().split()) map(int,input().split()) b cnt = 0 0 cnt
def division(n):
    if n < 2:
        return [1]

    prime_factors = [1]

    for i in range(2,int(n**0.5)+1):
        while n % i == 0:
            prime_factors.append(i)
            n //= i
    if n > 1:
        prime_factors.append(n)

    return prime_factors

a,b = map(int,input().split())
da = set(division(a))
db = set(division(b))
cnt = 0
for i in da:
    if i in db:
        cnt += 1
print(cnt)