A, B = map(int, input().split())
def factorization(n):
  M = n
  k = 1
  faclist = [1]
  while(k**2 <= M):
    k += 1
    if M%k == 0:
      count = 0
      while M%k == 0:
        M //= k
        count += 1
      faclist.append(k)
  if M > 1:
    faclist.append(M)
  return faclist

a = factorization(A)
b = factorization(B)
from collections import deque

a = deque(a)
ans = 0
def binary_search(list, item):
  low = 0
  high = len(list) - 1
  while low <= high:
    mid = (low + high) //2
    guess = list[mid]
    if guess == item:
      return 1
    if guess > item:
      high = mid -1
    else:
      low = mid + 1
  return 0
while a:
  item = a.popleft()
  ans += binary_search(b, item)
print(ans)
   A, B = map(int, input().split()) A map(int, input().split()) map int input().split() ().split () input split B def factorization(n):
  M = n
  k = 1
  faclist = [1]
  while(k**2 <= M):
    k += 1
    if M%k == 0:
      count = 0
      while M%k == 0:
        M //= k
        count += 1
      faclist.append(k)
  if M > 1:
    faclist.append(M)
  return faclist factorization M = n M n k = 1 k 1 faclist = [1] faclist [1] 1 while(k**2 <= M):
    k += 1
    if M%k == 0:
      count = 0
      while M%k == 0:
        M //= k
        count += 1
      faclist.append(k)
   k**2 <= M k**2 k 2 M k += 1 k 1 if M%k == 0:
      count = 0
      while M%k == 0:
        M //= k
        count += 1
      faclist.append(k)
   M%k == 0 M%k M k 0 count = 0 count 0 while M%k == 0:
        M //= k
        count += 1
       M%k == 0 M%k M k 0 M //= k M k count += 1 count 1 faclist.append(k) faclist.append faclist append k if M > 1:
    faclist.append(M)
   M > 1 M 1 faclist.append(M) faclist.append faclist append M return faclist faclist n n a = factorization(A) a factorization(A) factorization A b = factorization(B) b factorization(B) factorization B from collections import deque a = deque(a) a deque(a) deque a ans = 0 ans 0 def binary_search(list, item):
  low = 0
  high = len(list) - 1
  while low <= high:
    mid = (low + high) //2
    guess = list[mid]
    if guess == item:
      return 1
    if guess > item:
      high = mid -1
    else:
      low = mid + 1
  return 0 binary_search low = 0 low 0 high = len(list) - 1 high len(list) - 1 len(list) len list 1 while low <= high:
    mid = (low + high) //2
    guess = list[mid]
    if guess == item:
      return 1
    if guess > item:
      high = mid -1
    else:
      low = mid + 1
   low <= high low high mid = (low + high) //2 mid (low + high) //2 low + high low high 2 guess = list[mid] guess list[mid] list mid if guess == item:
      return 1
     guess == item guess item return 1 1 if guess > item:
      high = mid -1
    else:
      low = mid + 1
   guess > item guess item high = mid -1 high mid -1 mid 1 low = mid + 1 low mid + 1 mid 1 return 0 0 list list item item while a:
  item = a.popleft()
  ans += binary_search(b, item) a item = a.popleft() item a.popleft() a.popleft a popleft ans += binary_search(b, item) ans binary_search(b, item) binary_search b item print(ans) print ans B = map(int, input().split()) map(int, input().split()) B def binary_search(list, item):
  low = 0
  high = len(list) - 1
  while low <= high:
    mid = (low + high) //2
    guess = list[mid]
    if guess == item:
      return 1
    if guess > item:
      high = mid -1
    else:
      low = mid + 1
  return 0 def binary_search(list, item):
  low = 0
  high = len(list) - 1
  while low <= high:
    mid = (low + high) //2
    guess = list[mid]
    if guess == item:
      return 1
    if guess > item:
      high = mid -1
    else:
      low = mid + 1
  return 0 binary_search ans += binary_search(b, item) binary_search(b, item) ans A, B = map(int, input().split()) map(int, input().split()) A a = deque(a) deque(a) a a = factorization(A) factorization(A) a b = factorization(B) factorization(B) b ans = 0 0 ans item = a.popleft() a.popleft() item def factorization(n):
  M = n
  k = 1
  faclist = [1]
  while(k**2 <= M):
    k += 1
    if M%k == 0:
      count = 0
      while M%k == 0:
        M //= k
        count += 1
      faclist.append(k)
  if M > 1:
    faclist.append(M)
  return faclist def factorization(n):
  M = n
  k = 1
  faclist = [1]
  while(k**2 <= M):
    k += 1
    if M%k == 0:
      count = 0
      while M%k == 0:
        M //= k
        count += 1
      faclist.append(k)
  if M > 1:
    faclist.append(M)
  return faclist factorization
A, B = map(int, input().split())
def factorization(n):
  M = n
  k = 1
  faclist = [1]
  while(k**2 <= M):
    k += 1
    if M%k == 0:
      count = 0
      while M%k == 0:
        M //= k
        count += 1
      faclist.append(k)
  if M > 1:
    faclist.append(M)
  return faclist

a = factorization(A)
b = factorization(B)
from collections import deque

a = deque(a)
ans = 0
def binary_search(list, item):
  low = 0
  high = len(list) - 1
  while low <= high:
    mid = (low + high) //2
    guess = list[mid]
    if guess == item:
      return 1
    if guess > item:
      high = mid -1
    else:
      low = mid + 1
  return 0
while a:
  item = a.popleft()
  ans += binary_search(b, item)
print(ans)
  
