a,b=map(int,input().split())
 
def prime_factorization(n):
  if n==1:
    return [1]
  else:
    i=2
    ans=[]
    k=int(n**0.5)+1
    for j in range(2,k+1):
      if n==1: break
      if n%j==0:
        n//=j
        ans.append(j)
        while n%j==0:
          n//=j
    if len(ans):
      ans.append(1)
      if n!=1:
        ans.append(n)
      return ans
    else:
      return [1,n]

A=prime_factorization(a)
B=prime_factorization(b)
 
print(len(set(A)&set(B))) a,b=map(int,input().split()) a map(int,input().split()) map int input().split() ().split () input split b def prime_factorization(n):
  if n==1:
    return [1]
  else:
    i=2
    ans=[]
    k=int(n**0.5)+1
    for j in range(2,k+1):
      if n==1: break
      if n%j==0:
        n//=j
        ans.append(j)
        while n%j==0:
          n//=j
    if len(ans):
      ans.append(1)
      if n!=1:
        ans.append(n)
      return ans
    else:
      return [1,n] prime_factorization if n==1:
    return [1]
  else:
    i=2
    ans=[]
    k=int(n**0.5)+1
    for j in range(2,k+1):
      if n==1: break
      if n%j==0:
        n//=j
        ans.append(j)
        while n%j==0:
          n//=j
    if len(ans):
      ans.append(1)
      if n!=1:
        ans.append(n)
      return ans
    else:
      return [1,n] n==1 n 1 return [1] [1] 1 i=2 i 2 ans=[] ans [] k=int(n**0.5)+1 k int(n**0.5)+1 int(n**0.5) int n**0.5 n 0.5 1 for j in range(2,k+1):
      if n==1: break
      if n%j==0:
        n//=j
        ans.append(j)
        while n%j==0:
          n//=j
     j range(2,k+1) range 2 k+1 k 1 if n==1: break
       n==1 n 1 if n%j==0:
        n//=j
        ans.append(j)
        while n%j==0:
          n//=j
     n%j==0 n%j n j 0 n//=j n j ans.append(j) ans.append ans append j while n%j==0:
          n//=j
     n%j==0 n%j n j 0 n//=j n j if len(ans):
      ans.append(1)
      if n!=1:
        ans.append(n)
      return ans
    else:
      return [1,n] len(ans) len ans ans.append(1) ans.append ans append 1 if n!=1:
        ans.append(n)
       n!=1 n 1 ans.append(n) ans.append ans append n return ans ans return [1,n] [1,n] 1 n n n A=prime_factorization(a) A prime_factorization(a) prime_factorization a B=prime_factorization(b) B prime_factorization(b) prime_factorization b print(len(set(A)&set(B))) print len(set(A)&set(B)) len set(A)&set(B) set(A) set A set(B) set B B=prime_factorization(b) prime_factorization(b) B def prime_factorization(n):
  if n==1:
    return [1]
  else:
    i=2
    ans=[]
    k=int(n**0.5)+1
    for j in range(2,k+1):
      if n==1: break
      if n%j==0:
        n//=j
        ans.append(j)
        while n%j==0:
          n//=j
    if len(ans):
      ans.append(1)
      if n!=1:
        ans.append(n)
      return ans
    else:
      return [1,n] def prime_factorization(n):
  if n==1:
    return [1]
  else:
    i=2
    ans=[]
    k=int(n**0.5)+1
    for j in range(2,k+1):
      if n==1: break
      if n%j==0:
        n//=j
        ans.append(j)
        while n%j==0:
          n//=j
    if len(ans):
      ans.append(1)
      if n!=1:
        ans.append(n)
      return ans
    else:
      return [1,n] prime_factorization a,b=map(int,input().split()) map(int,input().split()) a b=map(int,input().split()) map(int,input().split()) b A=prime_factorization(a) prime_factorization(a) A
a,b=map(int,input().split())
 
def prime_factorization(n):
  if n==1:
    return [1]
  else:
    i=2
    ans=[]
    k=int(n**0.5)+1
    for j in range(2,k+1):
      if n==1: break
      if n%j==0:
        n//=j
        ans.append(j)
        while n%j==0:
          n//=j
    if len(ans):
      ans.append(1)
      if n!=1:
        ans.append(n)
      return ans
    else:
      return [1,n]

A=prime_factorization(a)
B=prime_factorization(b)
 
print(len(set(A)&set(B)))