def pfact(n):
    d = {}
    while n % 2 == 0:
        d[2] = 1 if 2 not in d else d[2] + 1
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            d[f] = 1 if f not in d else d[f] + 1
            n //= f
        else:
            f += 2
    if n != 1:
        d[n] = 1 if n not in d else d[n] + 1
    return d

a, b = map(int, input().split())
A = pfact(a)
B = pfact(b)
d = {}
ans = 1
for k in A.keys():
    if k in B:
        ans += 1
print(ans) def pfact(n):
    d = {}
    while n % 2 == 0:
        d[2] = 1 if 2 not in d else d[2] + 1
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            d[f] = 1 if f not in d else d[f] + 1
            n //= f
        else:
            f += 2
    if n != 1:
        d[n] = 1 if n not in d else d[n] + 1
    return d pfact d = {} d {} while n % 2 == 0:
        d[2] = 1 if 2 not in d else d[2] + 1
        n //= 2
     n % 2 == 0 n % 2 n 2 0 d[2] = 1 if 2 not in d else d[2] + 1 d[2] d 2 1 if 2 not in d else d[2] + 1 2 not in d 2 d 1 d[2] + 1 d[2] d 2 1 n //= 2 n 2 f = 3 f 3 while f * f <= n:
        if n % f == 0:
            d[f] = 1 if f not in d else d[f] + 1
            n //= f
        else:
            f += 2
     f * f <= n f * f f f n if n % f == 0:
            d[f] = 1 if f not in d else d[f] + 1
            n //= f
        else:
            f += 2
     n % f == 0 n % f n f 0 d[f] = 1 if f not in d else d[f] + 1 d[f] d f 1 if f not in d else d[f] + 1 f not in d f d 1 d[f] + 1 d[f] d f 1 n //= f n f f += 2 f 2 if n != 1:
        d[n] = 1 if n not in d else d[n] + 1
     n != 1 n 1 d[n] = 1 if n not in d else d[n] + 1 d[n] d n 1 if n not in d else d[n] + 1 n not in d n d 1 d[n] + 1 d[n] d n 1 return d d n n a, b = map(int, input().split()) a map(int, input().split()) map int input().split() ().split () input split b A = pfact(a) A pfact(a) pfact a B = pfact(b) B pfact(b) pfact b d = {} d {} ans = 1 ans 1 for k in A.keys():
    if k in B:
        ans += 1 k A.keys() A.keys A keys if k in B:
        ans += 1 k in B k B ans += 1 ans 1 print(ans) print ans a, b = map(int, input().split()) map(int, input().split()) a def pfact(n):
    d = {}
    while n % 2 == 0:
        d[2] = 1 if 2 not in d else d[2] + 1
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            d[f] = 1 if f not in d else d[f] + 1
            n //= f
        else:
            f += 2
    if n != 1:
        d[n] = 1 if n not in d else d[n] + 1
    return d def pfact(n):
    d = {}
    while n % 2 == 0:
        d[2] = 1 if 2 not in d else d[2] + 1
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            d[f] = 1 if f not in d else d[f] + 1
            n //= f
        else:
            f += 2
    if n != 1:
        d[n] = 1 if n not in d else d[n] + 1
    return d pfact B = pfact(b) pfact(b) B d = {} {} d ans = 1 1 ans ans += 1 1 ans A = pfact(a) pfact(a) A b = map(int, input().split()) map(int, input().split()) b
def pfact(n):
    d = {}
    while n % 2 == 0:
        d[2] = 1 if 2 not in d else d[2] + 1
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            d[f] = 1 if f not in d else d[f] + 1
            n //= f
        else:
            f += 2
    if n != 1:
        d[n] = 1 if n not in d else d[n] + 1
    return d

a, b = map(int, input().split())
A = pfact(a)
B = pfact(b)
d = {}
ans = 1
for k in A.keys():
    if k in B:
        ans += 1
print(ans)
