import math
#試し割法
def trial_division(n):
    #素因数を格納するリスト
    factor = []
    #2から√n以下の数字で割っていく
    tmp = int(math.sqrt(n)) + 1
    for num in range(2,tmp):
        while n % num == 0:
            n //= num
            factor.append(num)
    #リストが空ならそれは素数
    if not factor:
        factor.append(1)
        factor.append(n)
        return factor
    else:
        factor.append(1)
        factor.append(n)
        return factor
A,B=map(int,input().split())
A_primes=trial_division(A)
B_primes=trial_division(B)
primes=[]
for p in A_primes:
  if p in B_primes:
    primes.append(B_primes.pop(B_primes.index(p)))
print(len(list(set(primes)))) import math math def trial_division(n):
    #素因数を格納するリスト
    factor = []
    #2から√n以下の数字で割っていく
    tmp = int(math.sqrt(n)) + 1
    for num in range(2,tmp):
        while n % num == 0:
            n //= num
            factor.append(num)
    #リストが空ならそれは素数
    if not factor:
        factor.append(1)
        factor.append(n)
        return factor
    else:
        factor.append(1)
        factor.append(n)
        return factor trial_division factor = [] factor [] tmp = int(math.sqrt(n)) + 1 tmp int(math.sqrt(n)) + 1 int(math.sqrt(n)) int math.sqrt(n) math.sqrt math sqrt n 1 for num in range(2,tmp):
        while n % num == 0:
            n //= num
            factor.append(num)
    #リストが空ならそれは素数
     num range(2,tmp) range 2 tmp while n % num == 0:
            n //= num
            factor.append(num)
    #リストが空ならそれは素数
     n % num == 0 n % num n num 0 n //= num n num factor.append(num) factor.append factor append num if not factor:
        factor.append(1)
        factor.append(n)
        return factor
    else:
        factor.append(1)
        factor.append(n)
        return factor not factor factor factor.append(1) factor.append factor append 1 factor.append(n) factor.append factor append n return factor factor factor.append(1) factor.append factor append 1 factor.append(n) factor.append factor append n return factor factor n n A,B=map(int,input().split()) A map(int,input().split()) map int input().split() ().split () input split B A_primes=trial_division(A) A_primes trial_division(A) trial_division A B_primes=trial_division(B) B_primes trial_division(B) trial_division B primes=[] primes [] for p in A_primes:
  if p in B_primes:
    primes.append(B_primes.pop(B_primes.index(p))) p A_primes if p in B_primes:
    primes.append(B_primes.pop(B_primes.index(p))) p in B_primes p B_primes primes.append(B_primes.pop(B_primes.index(p))) primes.append primes append B_primes.pop(B_primes.index(p)) B_primes.pop B_primes pop B_primes.index(p) B_primes.index B_primes index p print(len(list(set(primes)))) print len(list(set(primes))) len list(set(primes)) list set(primes) set primes primes=[] [] primes def trial_division(n):
    #素因数を格納するリスト
    factor = []
    #2から√n以下の数字で割っていく
    tmp = int(math.sqrt(n)) + 1
    for num in range(2,tmp):
        while n % num == 0:
            n //= num
            factor.append(num)
    #リストが空ならそれは素数
    if not factor:
        factor.append(1)
        factor.append(n)
        return factor
    else:
        factor.append(1)
        factor.append(n)
        return factor def trial_division(n):
    #素因数を格納するリスト
    factor = []
    #2から√n以下の数字で割っていく
    tmp = int(math.sqrt(n)) + 1
    for num in range(2,tmp):
        while n % num == 0:
            n //= num
            factor.append(num)
    #リストが空ならそれは素数
    if not factor:
        factor.append(1)
        factor.append(n)
        return factor
    else:
        factor.append(1)
        factor.append(n)
        return factor trial_division B=map(int,input().split()) map(int,input().split()) B B_primes=trial_division(B) trial_division(B) B_primes A,B=map(int,input().split()) map(int,input().split()) A A_primes=trial_division(A) trial_division(A) A_primes
import math
#試し割法
def trial_division(n):
    #素因数を格納するリスト
    factor = []
    #2から√n以下の数字で割っていく
    tmp = int(math.sqrt(n)) + 1
    for num in range(2,tmp):
        while n % num == 0:
            n //= num
            factor.append(num)
    #リストが空ならそれは素数
    if not factor:
        factor.append(1)
        factor.append(n)
        return factor
    else:
        factor.append(1)
        factor.append(n)
        return factor
A,B=map(int,input().split())
A_primes=trial_division(A)
B_primes=trial_division(B)
primes=[]
for p in A_primes:
  if p in B_primes:
    primes.append(B_primes.pop(B_primes.index(p)))
print(len(list(set(primes))))
