def gcd(a,b):
  while b:a,b=b,a%b
  return a
def divisor(n):
  ass=[]
  for i in range(1,int(n**0.5)+1):
    if n%i==0:
      ass.append(i)
      if i!=n//i:ass.append(n//i)
  return ass
def is_prime(n):
  if n==1:return True;return False
  for i in range(2,int(n**0.5)+1):
    if n%i==0:return False
  return True
ans=0
a,b=map(int,input().split())
for i in divisor(gcd(a,b)):
  if is_prime(i):ans+=1
print(ans) def gcd(a,b):
  while b:a,b=b,a%b
  return a gcd while b:a,b=b,a%b
   b return a a a a b b def divisor(n):
  ass=[]
  for i in range(1,int(n**0.5)+1):
    if n%i==0:
      ass.append(i)
      if i!=n//i:ass.append(n//i)
  return ass divisor ass=[] ass [] for i in range(1,int(n**0.5)+1):
    if n%i==0:
      ass.append(i)
      if i!=n//i:ass.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:
      ass.append(i)
      if i!=n//i:ass.append(n//i)
   n%i==0 n%i n i 0 ass.append(i) ass.append ass append i if i!=n//i:ass.append(n//i)
   i!=n//i i n//i n i return ass ass n n def is_prime(n):
  if n==1:return True;return False
  for i in range(2,int(n**0.5)+1):
    if n%i==0:return False
  return True is_prime if n==1:return True;return False
   n==1 n 1 for i in range(2,int(n**0.5)+1):
    if n%i==0:return False
   i range(2,int(n**0.5)+1) range 2 int(n**0.5)+1 int(n**0.5) int n**0.5 n 0.5 1 if n%i==0:return False
   n%i==0 n%i n i 0 return True True n n ans=0 ans 0 a,b=map(int,input().split()) a map(int,input().split()) map int input().split() ().split () input split b for i in divisor(gcd(a,b)):
  if is_prime(i):ans+=1 i divisor(gcd(a,b)) divisor gcd(a,b) gcd a b if is_prime(i):ans+ is_prime(i) is_prime i print(ans) print ans a,b=map(int,input().split()) map(int,input().split()) a ans=0 0 ans b=map(int,input().split()) map(int,input().split()) b def gcd(a,b):
  while b:a,b=b,a%b
  return a def gcd(a,b):
  while b:a,b=b,a%b
  return a gcd def is_prime(n):
  if n==1:return True;return False
  for i in range(2,int(n**0.5)+1):
    if n%i==0:return False
  return True def is_prime(n):
  if n==1:return True;return False
  for i in range(2,int(n**0.5)+1):
    if n%i==0:return False
  return True is_prime def divisor(n):
  ass=[]
  for i in range(1,int(n**0.5)+1):
    if n%i==0:
      ass.append(i)
      if i!=n//i:ass.append(n//i)
  return ass def divisor(n):
  ass=[]
  for i in range(1,int(n**0.5)+1):
    if n%i==0:
      ass.append(i)
      if i!=n//i:ass.append(n//i)
  return ass divisor
def gcd(a,b):
  while b:a,b=b,a%b
  return a
def divisor(n):
  ass=[]
  for i in range(1,int(n**0.5)+1):
    if n%i==0:
      ass.append(i)
      if i!=n//i:ass.append(n//i)
  return ass
def is_prime(n):
  if n==1:return True;return False
  for i in range(2,int(n**0.5)+1):
    if n%i==0:return False
  return True
ans=0
a,b=map(int,input().split())
for i in divisor(gcd(a,b)):
  if is_prime(i):ans+=1
print(ans)