import math

a,b=list(map(int,input().split()))
min_num=min(a,b)
gcd=[]

def prime(n):
  if n==1:
    return True
  for i in range(2,int(math.sqrt(n))+1):
    if n%i==0:
      return False
  return True

for i in range(1,int(math.sqrt(min_num)+1)):
  if a%i==0:
    if b%i==0:
      gcd.append(i)
    if b%(a//i)==0:
      gcd.append(a//i)

prime_list=[]
for i in gcd:
  if prime(i):
    prime_list.append(i)
if a==1 or b==1:
  print(len(prime_list)-1)
else:
  print(len(prime_list))


    


      
   import math math a,b=list(map(int,input().split())) a list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split b min_num=min(a,b) min_num min(a,b) min a b gcd=[] gcd [] def prime(n):
  if n==1:
    return True
  for i in range(2,int(math.sqrt(n))+1):
    if n%i==0:
      return False
  return True prime if n==1:
    return True
   n==1 n 1 return True True for i in range(2,int(math.sqrt(n))+1):
    if n%i==0:
      return False
   i range(2,int(math.sqrt(n))+1) range 2 int(math.sqrt(n))+1 int(math.sqrt(n)) int math.sqrt(n) math.sqrt math sqrt n 1 if n%i==0:
      return False
   n%i==0 n%i n i 0 return False False return True True n n for i in range(1,int(math.sqrt(min_num)+1)):
  if a%i==0:
    if b%i==0:
      gcd.append(i)
    if b%(a//i)==0:
      gcd.append(a//i) i range(1,int(math.sqrt(min_num)+1)) range 1 int(math.sqrt(min_num)+1) int math.sqrt(min_num)+1 math.sqrt(min_num) math.sqrt math sqrt min_num 1 if a%i==0:
    if b%i==0:
      gcd.append(i)
    if b%(a//i)==0:
      gcd.append(a//i) a%i==0 a%i a i 0 if b%i==0:
      gcd.append(i)
     b%i==0 b%i b i 0 gcd.append(i) gcd.append gcd append i if b%(a//i)==0:
      gcd.append(a//i) b%(a//i)==0 b%(a//i) b a//i a i 0 gcd.append(a//i) gcd.append gcd append a//i a i prime_list=[] prime_list [] for i in gcd:
  if prime(i):
    prime_list.append(i) i gcd if prime(i):
    prime_list.append(i) prime(i) prime i prime_list.append(i) prime_list.append prime_list append i if a==1 or b==1:
  print(len(prime_list)-1)
else:
  print(len(prime_list))


    


      
   a==1 or b==1 a==1 a 1 b==1 b 1 print(len(prime_list)-1) print len(prime_list)-1 len(prime_list) len prime_list 1 print(len(prime_list)) print len(prime_list) len prime_list a,b=list(map(int,input().split())) list(map(int,input().split())) a prime_list=[] [] prime_list b=list(map(int,input().split())) list(map(int,input().split())) b min_num=min(a,b) min(a,b) min_num def prime(n):
  if n==1:
    return True
  for i in range(2,int(math.sqrt(n))+1):
    if n%i==0:
      return False
  return True def prime(n):
  if n==1:
    return True
  for i in range(2,int(math.sqrt(n))+1):
    if n%i==0:
      return False
  return True prime gcd=[] [] gcd
import math

a,b=list(map(int,input().split()))
min_num=min(a,b)
gcd=[]

def prime(n):
  if n==1:
    return True
  for i in range(2,int(math.sqrt(n))+1):
    if n%i==0:
      return False
  return True

for i in range(1,int(math.sqrt(min_num)+1)):
  if a%i==0:
    if b%i==0:
      gcd.append(i)
    if b%(a//i)==0:
      gcd.append(a//i)

prime_list=[]
for i in gcd:
  if prime(i):
    prime_list.append(i)
if a==1 or b==1:
  print(len(prime_list)-1)
else:
  print(len(prime_list))


    


      
  
