import fractions

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

def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]

l = sorted(list(set(make_divisors(A)) & set(make_divisors(B))))
#print(l)
i = 0
while i < len(l):
    v = l[i]
    if v == 1:
        i += 1
        continue
    l = l[0:i+1] + list(filter(lambda x: x % v != 0, l[i+1:]))
#    print(l)
    i += 1
print(len(l)) import fractions fractions A, B = list(map(int, input().split())) A list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split B def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1] make_divisors lower_divisors , upper_divisors = [], [] lower_divisors [] upper_divisors [] i = 1 i 1 while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
     i*i <= n i*i i i n if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
         n % i == 0 n % i n i 0 lower_divisors.append(i) lower_divisors.append lower_divisors append i if i != n // i:
                upper_divisors.append(n//i)
         i != n // i i n // i n i upper_divisors.append(n//i) upper_divisors.append upper_divisors append n//i n i i += 1 i 1 return lower_divisors + upper_divisors[::-1] lower_divisors + upper_divisors[::-1] lower_divisors upper_divisors[::-1] upper_divisors ::-1 -1 n n l = sorted(list(set(make_divisors(A)) & set(make_divisors(B)))) l sorted(list(set(make_divisors(A)) & set(make_divisors(B)))) sorted 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 i = 0 i 0 while i < len(l):
    v = l[i]
    if v == 1:
        i += 1
        continue
    l = l[0:i+1] + list(filter(lambda x: x % v != 0, l[i+1:]))
#    print(l)
    i += 1 i < len(l) i len(l) len l v = l[i] v l[i] l i if v == 1:
        i += 1
        continue
     v == 1 v 1 i += 1 i 1 continue l = l[0:i+1] + list(filter(lambda x: x % v != 0, l[i+1:])) l l[0:i+1] + list(filter(lambda x: x % v != 0, l[i+1:])) l[0:i+1] l 0:i+1 0 i+1 i 1 list(filter(lambda x: x % v != 0, l[i+1:])) list filter(lambda x: x % v != 0, l[i+1:]) filter lambda x: x % v != 0 x % v != 0 x % v x v 0 x l[i+1:] l i+1: i+1 i 1 i += 1 i 1 print(len(l)) print len(l) len l B = list(map(int, input().split())) list(map(int, input().split())) B l = sorted(list(set(make_divisors(A)) & set(make_divisors(B)))) sorted(list(set(make_divisors(A)) & set(make_divisors(B)))) l i += 1 1 i i = 0 0 i v = l[i] l[i] v A, B = list(map(int, input().split())) list(map(int, input().split())) A i += 1 1 i def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1] def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1] make_divisors l = l[0:i+1] + list(filter(lambda x: x % v != 0, l[i+1:])) l[0:i+1] + list(filter(lambda x: x % v != 0, l[i+1:])) l
import fractions

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

def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]

l = sorted(list(set(make_divisors(A)) & set(make_divisors(B))))
#print(l)
i = 0
while i < len(l):
    v = l[i]
    if v == 1:
        i += 1
        continue
    l = l[0:i+1] + list(filter(lambda x: x % v != 0, l[i+1:]))
#    print(l)
    i += 1
print(len(l))
