a,b=map(int,input().split())
pfa={}
m=a
for i in range(2,int(m**0.5)+1):
    while m%i==0:
        pfa[i]=pfa.get(i,0)+1
        m//=i
if m>1:pfa[m]=1
pfb={}
m=b
for i in range(2,int(m**0.5)+1):
    while m%i==0:
        pfb[i]=pfb.get(i,0)+1
        m//=i
if m>1:pfb[m]=1
aa=set()
bb=set()
for i in pfa.keys():
    aa.add(i)
for i in pfb.keys():
    bb.add(i)
print(len(aa&bb)+1) a,b=map(int,input().split()) a map(int,input().split()) map int input().split() ().split () input split b pfa={} pfa {} m=a m a for i in range(2,int(m**0.5)+1):
    while m%i==0:
        pfa[i]=pfa.get(i,0)+1
        m//=i i range(2,int(m**0.5)+1) range 2 int(m**0.5)+1 int(m**0.5) int m**0.5 m 0.5 1 while m%i==0:
        pfa[i]=pfa.get(i,0)+1
        m//=i m%i==0 m%i m i 0 pfa[i]=pfa.get(i,0)+1 pfa[i] pfa i pfa.get(i,0)+1 pfa.get(i,0) pfa.get pfa get i 0 1 m//=i m i if m>1:pfa[m]=1 m>1 m 1 pfb={} pfb {} m=b m b for i in range(2,int(m**0.5)+1):
    while m%i==0:
        pfb[i]=pfb.get(i,0)+1
        m//=i i range(2,int(m**0.5)+1) range 2 int(m**0.5)+1 int(m**0.5) int m**0.5 m 0.5 1 while m%i==0:
        pfb[i]=pfb.get(i,0)+1
        m//=i m%i==0 m%i m i 0 pfb[i]=pfb.get(i,0)+1 pfb[i] pfb i pfb.get(i,0)+1 pfb.get(i,0) pfb.get pfb get i 0 1 m//=i m i if m>1:pfb[m]=1 m>1 m 1 aa=set() aa set() set bb=set() bb set() set for i in pfa.keys():
    aa.add(i) i pfa.keys() pfa.keys pfa keys aa.add(i) aa.add aa add i for i in pfb.keys():
    bb.add(i) i pfb.keys() pfb.keys pfb keys bb.add(i) bb.add bb add i print(len(aa&bb)+1) print len(aa&bb)+1 len(aa&bb) len aa&bb aa bb 1 a,b=map(int,input().split()) map(int,input().split()) a pfa={} {} pfa m//=i i m b=map(int,input().split()) map(int,input().split()) b m//=i i m bb=set() set() bb aa=set() set() aa pfb={} {} pfb m=b b m m=a a m
a,b=map(int,input().split())
pfa={}
m=a
for i in range(2,int(m**0.5)+1):
    while m%i==0:
        pfa[i]=pfa.get(i,0)+1
        m//=i
if m>1:pfa[m]=1
pfb={}
m=b
for i in range(2,int(m**0.5)+1):
    while m%i==0:
        pfb[i]=pfb.get(i,0)+1
        m//=i
if m>1:pfb[m]=1
aa=set()
bb=set()
for i in pfa.keys():
    aa.add(i)
for i in pfb.keys():
    bb.add(i)
print(len(aa&bb)+1)