
from collections import Counter
def prime_decomposition(n):
  i = 2
  table = []
  while i * i <= n:
    while n % i == 0:
      n //= i
      table.append(i)
    i += 1
  if n > 1:
    table.append(n)
  return table

A,B = map(int,input().split())
p1 = Counter(prime_decomposition(A))
p2 = Counter(prime_decomposition(B))
ans = 1
for p,_ in p1.items():
  if p2[p] > 0:
    ans += 1

print(ans) from collections import Counter def prime_decomposition(n):
  i = 2
  table = []
  while i * i <= n:
    while n % i == 0:
      n //= i
      table.append(i)
    i += 1
  if n > 1:
    table.append(n)
  return table prime_decomposition i = 2 i 2 table = [] table [] while i * i <= n:
    while n % i == 0:
      n //= i
      table.append(i)
    i += 1
   i * i <= n i * i i i n while n % i == 0:
      n //= i
      table.append(i)
     n % i == 0 n % i n i 0 n //= i n i table.append(i) table.append table append i i += 1 i 1 if n > 1:
    table.append(n)
   n > 1 n 1 table.append(n) table.append table append n return table table n n A,B = map(int,input().split()) A map(int,input().split()) map int input().split() ().split () input split B p1 = Counter(prime_decomposition(A)) p1 Counter(prime_decomposition(A)) Counter prime_decomposition(A) prime_decomposition A p2 = Counter(prime_decomposition(B)) p2 Counter(prime_decomposition(B)) Counter prime_decomposition(B) prime_decomposition B ans = 1 ans 1 for p,_ in p1.items():
  if p2[p] > 0:
    ans += 1 p _ p1.items() p1.items p1 items if p2[p] > 0:
    ans += 1 p2[p] > 0 p2[p] p2 p 0 ans += 1 ans 1 print(ans) print ans A,B = map(int,input().split()) map(int,input().split()) A def prime_decomposition(n):
  i = 2
  table = []
  while i * i <= n:
    while n % i == 0:
      n //= i
      table.append(i)
    i += 1
  if n > 1:
    table.append(n)
  return table def prime_decomposition(n):
  i = 2
  table = []
  while i * i <= n:
    while n % i == 0:
      n //= i
      table.append(i)
    i += 1
  if n > 1:
    table.append(n)
  return table prime_decomposition B = map(int,input().split()) map(int,input().split()) B p1 = Counter(prime_decomposition(A)) Counter(prime_decomposition(A)) p1 ans = 1 1 ans p2 = Counter(prime_decomposition(B)) Counter(prime_decomposition(B)) p2 ans += 1 1 ans

from collections import Counter
def prime_decomposition(n):
  i = 2
  table = []
  while i * i <= n:
    while n % i == 0:
      n //= i
      table.append(i)
    i += 1
  if n > 1:
    table.append(n)
  return table

A,B = map(int,input().split())
p1 = Counter(prime_decomposition(A))
p2 = Counter(prime_decomposition(B))
ans = 1
for p,_ in p1.items():
  if p2[p] > 0:
    ans += 1

print(ans)