def make_divisors(n):
    from collections import deque
    divisors = deque([])
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    lst_divisors = list(divisors)
    lst_divisors.sort()
    return lst_divisors

a, b = map(int,input().split())

ya = set(make_divisors(a))
yb = set(make_divisors(b))

cand = list(ya&yb)
cand.sort()

#print(cand)

ans = []
if len(cand) > 1:
    for n in cand[1:]:
        if ans:
            for waru in ans:
                if n%waru == 0:
                    break
            else:
                ans.append(n)
        else:
            ans.append(n)
#print(ans)
print(len(ans)+1) def make_divisors(n):
    from collections import deque
    divisors = deque([])
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    lst_divisors = list(divisors)
    lst_divisors.sort()
    return lst_divisors make_divisors from collections import deque divisors = deque([]) divisors deque([]) deque [] for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
     i range(1, int(n**0.5)+1) range 1 int(n**0.5)+1 int(n**0.5) int n**0.5 n 0.5 1 if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
     n % i == 0 n % i n i 0 divisors.append(i) divisors.append divisors append i if i != n // i:
                divisors.append(n//i)
     i != n // i i n // i n i divisors.append(n//i) divisors.append divisors append n//i n i lst_divisors = list(divisors) lst_divisors list(divisors) list divisors lst_divisors.sort() lst_divisors.sort lst_divisors sort return lst_divisors lst_divisors n n a, b = map(int,input().split()) a map(int,input().split()) map int input().split() ().split () input split b ya = set(make_divisors(a)) ya set(make_divisors(a)) set make_divisors(a) make_divisors a yb = set(make_divisors(b)) yb set(make_divisors(b)) set make_divisors(b) make_divisors b cand = list(ya&yb) cand list(ya&yb) list ya&yb ya yb cand.sort() cand.sort cand sort ans = [] ans [] if len(cand) > 1:
    for n in cand[1:]:
        if ans:
            for waru in ans:
                if n%waru == 0:
                    break
            else:
                ans.append(n)
        else:
            ans.append(n)
#print(ans) len(cand) > 1 len(cand) len cand 1 for n in cand[1:]:
        if ans:
            for waru in ans:
                if n%waru == 0:
                    break
            else:
                ans.append(n)
        else:
            ans.append(n)
#print(ans) n cand[1:] cand 1: 1 if ans:
            for waru in ans:
                if n%waru == 0:
                    break
            else:
                ans.append(n)
        else:
            ans.append(n)
#print(ans) ans for waru in ans:
                if n%waru == 0:
                    break
            else:
                ans.append(n)
         waru ans if n%waru == 0:
                    break
             n%waru == 0 n%waru n waru 0 break ans.append(n) ans.append ans append n ans.append(n) ans.append ans append n print(len(ans)+1) print len(ans)+1 len(ans) len ans 1 b = map(int,input().split()) map(int,input().split()) b ans = [] [] ans yb = set(make_divisors(b)) set(make_divisors(b)) yb def make_divisors(n):
    from collections import deque
    divisors = deque([])
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    lst_divisors = list(divisors)
    lst_divisors.sort()
    return lst_divisors def make_divisors(n):
    from collections import deque
    divisors = deque([])
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    lst_divisors = list(divisors)
    lst_divisors.sort()
    return lst_divisors make_divisors cand = list(ya&yb) list(ya&yb) cand a, b = map(int,input().split()) map(int,input().split()) a ya = set(make_divisors(a)) set(make_divisors(a)) ya
def make_divisors(n):
    from collections import deque
    divisors = deque([])
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    lst_divisors = list(divisors)
    lst_divisors.sort()
    return lst_divisors

a, b = map(int,input().split())

ya = set(make_divisors(a))
yb = set(make_divisors(b))

cand = list(ya&yb)
cand.sort()

#print(cand)

ans = []
if len(cand) > 1:
    for n in cand[1:]:
        if ans:
            for waru in ans:
                if n%waru == 0:
                    break
            else:
                ans.append(n)
        else:
            ans.append(n)
#print(ans)
print(len(ans)+1)