def make_divisors(n:int) -> list:
    """約数を列挙"""
    lower_divisors, upper_divisors = [], []
    i = 1
    while i * i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]

import math
def isPrime(n):
  if n == 2:
    return True
  if n % 2 == 0:
    return False
  m = math.floor(math.sqrt(n)) + 1
  for p in range(3, m, 2):
      if n % p == 0:
        return False
  return True

A, B = map(int, input().split())
div_A = make_divisors(A)
div_B = make_divisors(B)
cd = (set(div_A) & set(div_B))
ans = 0
for n in cd:
    if isPrime(n):
        ans += 1
print(ans) def make_divisors(n:int) -> list:
    """約数を列挙"""
    lower_divisors, upper_divisors = [], []
    i = 1
    while i * i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1] make_divisors """約数を列挙""" lower_divisors, upper_divisors = [], [] lower_divisors [] upper_divisors [] i = 1 i 1 while i * i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
     i * i <= n i * i i i n if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
         n % i == 0 n % i n i 0 lower_divisors.append(i) lower_divisors.append lower_divisors append i if i != n // i:
                upper_divisors.append(n//i)
         i != n // i i n // i n i upper_divisors.append(n//i) upper_divisors.append upper_divisors append n//i n i i += 1 i 1 return lower_divisors + upper_divisors[::-1] lower_divisors + upper_divisors[::-1] lower_divisors upper_divisors[::-1] upper_divisors ::-1 -1 n:int n import math math def isPrime(n):
  if n == 2:
    return True
  if n % 2 == 0:
    return False
  m = math.floor(math.sqrt(n)) + 1
  for p in range(3, m, 2):
      if n % p == 0:
        return False
  return True isPrime if n == 2:
    return True
   n == 2 n 2 return True True if n % 2 == 0:
    return False
   n % 2 == 0 n % 2 n 2 0 return False False m = math.floor(math.sqrt(n)) + 1 m math.floor(math.sqrt(n)) + 1 math.floor(math.sqrt(n)) math.floor math floor math.sqrt(n) math.sqrt math sqrt n 1 for p in range(3, m, 2):
      if n % p == 0:
        return False
   p range(3, m, 2) range 3 m 2 if n % p == 0:
        return False
   n % p == 0 n % p n p 0 return False False return True True n n A, B = map(int, input().split()) A map(int, input().split()) map int input().split() ().split () input split B div_A = make_divisors(A) div_A make_divisors(A) make_divisors A div_B = make_divisors(B) div_B make_divisors(B) make_divisors B cd = (set(div_A) & set(div_B)) cd set(div_A) & set(div_B) set(div_A) set div_A set(div_B) set div_B ans = 0 ans 0 for n in cd:
    if isPrime(n):
        ans += 1 n cd if isPrime(n):
        ans += 1 isPrime(n) isPrime n ans += 1 ans 1 print(ans) print ans def isPrime(n):
  if n == 2:
    return True
  if n % 2 == 0:
    return False
  m = math.floor(math.sqrt(n)) + 1
  for p in range(3, m, 2):
      if n % p == 0:
        return False
  return True def isPrime(n):
  if n == 2:
    return True
  if n % 2 == 0:
    return False
  m = math.floor(math.sqrt(n)) + 1
  for p in range(3, m, 2):
      if n % p == 0:
        return False
  return True isPrime div_B = make_divisors(B) make_divisors(B) div_B ans = 0 0 ans A, B = map(int, input().split()) map(int, input().split()) A B = map(int, input().split()) map(int, input().split()) B ans += 1 1 ans div_A = make_divisors(A) make_divisors(A) div_A cd = (set(div_A) & set(div_B)) set(div_A) & set(div_B) cd def make_divisors(n:int) -> list:
    """約数を列挙"""
    lower_divisors, upper_divisors = [], []
    i = 1
    while i * i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1] def make_divisors(n:int) -> list:
    """約数を列挙"""
    lower_divisors, upper_divisors = [], []
    i = 1
    while i * i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1] make_divisors
def make_divisors(n:int) -> list:
    """約数を列挙"""
    lower_divisors, upper_divisors = [], []
    i = 1
    while i * i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]

import math
def isPrime(n):
  if n == 2:
    return True
  if n % 2 == 0:
    return False
  m = math.floor(math.sqrt(n)) + 1
  for p in range(3, m, 2):
      if n % p == 0:
        return False
  return True

A, B = map(int, input().split())
div_A = make_divisors(A)
div_B = make_divisors(B)
cd = (set(div_A) & set(div_B))
ans = 0
for n in cd:
    if isPrime(n):
        ans += 1
print(ans)