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]

a,b=map(int,input().split())
a=make_divisors(a)
b=make_divisors(b)
a=set(a)
b=set(b)
s=sorted(a&b)
ans=[1]
for i in s[1:]:
    switch=0
    for j in ans[1:]:
        if i%j==0:
            switch=1
            break
    if switch==0:
        ans.append(i)
print(len(ans)) 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 a,b=map(int,input().split()) a map(int,input().split()) map int input().split() ().split () input split b a=make_divisors(a) a make_divisors(a) make_divisors a b=make_divisors(b) b make_divisors(b) make_divisors b a=set(a) a set(a) set a b=set(b) b set(b) set b s=sorted(a&b) s sorted(a&b) sorted a&b a b ans=[1] ans [1] 1 for i in s[1:]:
    switch=0
    for j in ans[1:]:
        if i%j==0:
            switch=1
            break
    if switch==0:
        ans.append(i) i s[1:] s 1: 1 switch=0 switch 0 for j in ans[1:]:
        if i%j==0:
            switch=1
            break
     j ans[1:] ans 1: 1 if i%j==0:
            switch=1
            break
     i%j==0 i%j i j 0 switch=1 switch 1 break if switch==0:
        ans.append(i) switch==0 switch 0 ans.append(i) ans.append ans append i print(len(ans)) print len(ans) len ans b=map(int,input().split()) map(int,input().split()) b s=sorted(a&b) sorted(a&b) s ans=[1] [1] ans switch=0 0 switch b=make_divisors(b) make_divisors(b) 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] 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 a,b=map(int,input().split()) map(int,input().split()) a switch=1 1 switch b=set(b) set(b) b a=make_divisors(a) make_divisors(a) a a=set(a) set(a) a
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]

a,b=map(int,input().split())
a=make_divisors(a)
b=make_divisors(b)
a=set(a)
b=set(b)
s=sorted(a&b)
ans=[1]
for i in s[1:]:
    switch=0
    for j in ans[1:]:
        if i%j==0:
            switch=1
            break
    if switch==0:
        ans.append(i)
print(len(ans))