from sys import stdin,stdout
def INPUT():return list(int(i) for i in stdin.readline().split())
import math
def inp():return stdin.readline()
def out(x):return stdout.write(x)
import math as M
MOD=10**9+7
import random
#####################################
a,b=INPUT()
A=min(a,b)
B=max(a,b)
X=[]
P=[]
for i in range(1,int(M.sqrt(A)+1)):
    if A%i==0:
        if A//i==i:
            P.append(i)
        else:
            P.append(i)
            P.append(A//i)
Q=[]

for i in range(1,int(M.sqrt(B)+1)):
    if B%i==0:
        if B//i==i:
            Q.append(i)
        else:
            Q.append(i)
            Q.append(B//i)
X=list(set(P)&set(Q))
X.sort()
ans=0
#sprint(X)
bool=[True]*len(X)
for i in range(len(X)):
    if X[i]!=1 and bool[i]==True:
        ele=X[i]
        for j in range(i+1,len(X)):
            if X[j]%ele==0:
                bool[j]=False

for i in range(len(X)):
    if bool[i]==True:
        ans+=1

print(ans) from sys import stdin,stdout def INPUT():return list(int(i) for i in stdin.readline().split()) INPUT import math math def inp():return stdin.readline() inp def out(x):return stdout.write(x) out x x import math as M math MOD=10**9+7 MOD 10**9+7 10**9 10 9 7 import random random a,b=INPUT() a INPUT() INPUT b A=min(a,b) A min(a,b) min a b B=max(a,b) B max(a,b) max a b X=[] X [] P=[] P [] for i in range(1,int(M.sqrt(A)+1)):
    if A%i==0:
        if A//i==i:
            P.append(i)
        else:
            P.append(i)
            P.append(A//i) i range(1,int(M.sqrt(A)+1)) range 1 int(M.sqrt(A)+1) int M.sqrt(A)+1 M.sqrt(A) M.sqrt M sqrt A 1 if A%i==0:
        if A//i==i:
            P.append(i)
        else:
            P.append(i)
            P.append(A//i) A%i==0 A%i A i 0 if A//i==i:
            P.append(i)
        else:
            P.append(i)
            P.append(A//i) A//i==i A//i A i i P.append(i) P.append P append i P.append(i) P.append P append i P.append(A//i) P.append P append A//i A i Q=[] Q [] for i in range(1,int(M.sqrt(B)+1)):
    if B%i==0:
        if B//i==i:
            Q.append(i)
        else:
            Q.append(i)
            Q.append(B//i) i range(1,int(M.sqrt(B)+1)) range 1 int(M.sqrt(B)+1) int M.sqrt(B)+1 M.sqrt(B) M.sqrt M sqrt B 1 if B%i==0:
        if B//i==i:
            Q.append(i)
        else:
            Q.append(i)
            Q.append(B//i) B%i==0 B%i B i 0 if B//i==i:
            Q.append(i)
        else:
            Q.append(i)
            Q.append(B//i) B//i==i B//i B i i Q.append(i) Q.append Q append i Q.append(i) Q.append Q append i Q.append(B//i) Q.append Q append B//i B i X=list(set(P)&set(Q)) X list(set(P)&set(Q)) list set(P)&set(Q) set(P) set P set(Q) set Q X.sort() X.sort X sort ans=0 ans 0 bool=[True]*len(X) bool [True]*len(X) [True] True len(X) len X for i in range(len(X)):
    if X[i]!=1 and bool[i]==True:
        ele=X[i]
        for j in range(i+1,len(X)):
            if X[j]%ele==0:
                bool[j]=False i range(len(X)) range len(X) len X if X[i]!=1 and bool[i]==True:
        ele=X[i]
        for j in range(i+1,len(X)):
            if X[j]%ele==0:
                bool[j]=False X[i]!=1 and bool[i]==True X[i]!=1 X[i] X i 1 bool[i]==True bool[i] bool i True ele=X[i] ele X[i] X i for j in range(i+1,len(X)):
            if X[j]%ele==0:
                bool[j]=False j range(i+1,len(X)) range i+1 i 1 len(X) len X if X[j]%ele==0:
                bool[j]=False X[j]%ele==0 X[j]%ele X[j] X j ele 0 bool[j]=False bool[j] bool j False for i in range(len(X)):
    if bool[i]==True:
        ans+=1 i range(len(X)) range len(X) len X if bool[i]==True:
        ans+=1 bool[i]==True bool[i] bool i True ans+=1 ans 1 print(ans) print ans a,b=INPUT() INPUT() a def inp():return stdin.readline() def inp():return stdin.readline() inp P=[] [] P bool=[True]*len(X) [True]*len(X) bool def out(x):return stdout.write(x) def out(x):return stdout.write(x) out def INPUT():return list(int(i) for i in stdin.readline().split()) def INPUT():return list(int(i) for i in stdin.readline().split()) INPUT X=list(set(P)&set(Q)) list(set(P)&set(Q)) X ele=X[i] X[i] ele B=max(a,b) max(a,b) B X=[] [] X Q=[] [] Q ans+=1 1 ans ans=0 0 ans b=INPUT() INPUT() b MOD=10**9+7 10**9+7 MOD A=min(a,b) min(a,b) A
from sys import stdin,stdout
def INPUT():return list(int(i) for i in stdin.readline().split())
import math
def inp():return stdin.readline()
def out(x):return stdout.write(x)
import math as M
MOD=10**9+7
import random
#####################################
a,b=INPUT()
A=min(a,b)
B=max(a,b)
X=[]
P=[]
for i in range(1,int(M.sqrt(A)+1)):
    if A%i==0:
        if A//i==i:
            P.append(i)
        else:
            P.append(i)
            P.append(A//i)
Q=[]

for i in range(1,int(M.sqrt(B)+1)):
    if B%i==0:
        if B//i==i:
            Q.append(i)
        else:
            Q.append(i)
            Q.append(B//i)
X=list(set(P)&set(Q))
X.sort()
ans=0
#sprint(X)
bool=[True]*len(X)
for i in range(len(X)):
    if X[i]!=1 and bool[i]==True:
        ele=X[i]
        for j in range(i+1,len(X)):
            if X[j]%ele==0:
                bool[j]=False

for i in range(len(X)):
    if bool[i]==True:
        ans+=1

print(ans)
