def make_divisors(n):
    divisors = []
    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)

    divisors.sort()
    return divisors


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

lst=make_divisors(a)
sin_lst=[]

for i in lst:
  if b%i==0:
    sin_lst.append(i)

if len(sin_lst)==1:
  print(1)
  exit()

lst=[]
lst.append(sin_lst[1])

for i in sin_lst[2:]:
  flag=True
  for j in lst:
    if i%j==0:
      flag=False
      break
  
  if  flag:
    lst.append(i)


print(len(lst)+1) def make_divisors(n):
    divisors = []
    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)

    divisors.sort()
    return divisors make_divisors divisors = [] divisors [] 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 divisors.sort() divisors.sort divisors sort return divisors divisors n n a,b=map(int,input().split()) a map(int,input().split()) map int input().split() ().split () input split b lst=make_divisors(a) lst make_divisors(a) make_divisors a sin_lst=[] sin_lst [] for i in lst:
  if b%i==0:
    sin_lst.append(i) i lst if b%i==0:
    sin_lst.append(i) b%i==0 b%i b i 0 sin_lst.append(i) sin_lst.append sin_lst append i if len(sin_lst)==1:
  print(1)
  exit() len(sin_lst)==1 len(sin_lst) len sin_lst 1 print(1) print 1 exit() exit lst=[] lst [] lst.append(sin_lst[1]) lst.append lst append sin_lst[1] sin_lst 1 for i in sin_lst[2:]:
  flag=True
  for j in lst:
    if i%j==0:
      flag=False
      break
  
  if  flag:
    lst.append(i) i sin_lst[2:] sin_lst 2: 2 flag=True flag True for j in lst:
    if i%j==0:
      flag=False
      break
  
   j lst if i%j==0:
      flag=False
      break
  
   i%j==0 i%j i j 0 flag=False flag False break if  flag:
    lst.append(i) flag lst.append(i) lst.append lst append i print(len(lst)+1) print len(lst)+1 len(lst) len lst 1 lst=make_divisors(a) make_divisors(a) lst a,b=map(int,input().split()) map(int,input().split()) a def make_divisors(n):
    divisors = []
    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)

    divisors.sort()
    return divisors def make_divisors(n):
    divisors = []
    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)

    divisors.sort()
    return divisors make_divisors b=map(int,input().split()) map(int,input().split()) b lst=[] [] lst flag=True True flag flag=False False flag sin_lst=[] [] sin_lst
def make_divisors(n):
    divisors = []
    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)

    divisors.sort()
    return divisors


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

lst=make_divisors(a)
sin_lst=[]

for i in lst:
  if b%i==0:
    sin_lst.append(i)

if len(sin_lst)==1:
  print(1)
  exit()

lst=[]
lst.append(sin_lst[1])

for i in sin_lst[2:]:
  flag=True
  for j in lst:
    if i%j==0:
      flag=False
      break
  
  if  flag:
    lst.append(i)


print(len(lst)+1)