a,b=map(int,input().split())
A=[1]
for i in range(2,int(a**0.5)+1):
    if a%i==0:
        while a%i==0:
            a//=i
        A.append(i)
if a>1:
    A.append(a)
B=[1]
for i in range(2,int(b**0.5)+1):
    if b%i==0:
        while b%i==0:
            b//=i
        B.append(i)
if b>1:
    B.append(b)
can=0
for i in A:
    if i in B:
        can+=1
print(can) a,b=map(int,input().split()) a map(int,input().split()) map int input().split() ().split () input split b A=[1] A [1] 1 for i in range(2,int(a**0.5)+1):
    if a%i==0:
        while a%i==0:
            a//=i
        A.append(i) i range(2,int(a**0.5)+1) range 2 int(a**0.5)+1 int(a**0.5) int a**0.5 a 0.5 1 if a%i==0:
        while a%i==0:
            a//=i
        A.append(i) a%i==0 a%i a i 0 while a%i==0:
            a//=i
         a%i==0 a%i a i 0 a//=i a i A.append(i) A.append A append i if a>1:
    A.append(a) a>1 a 1 A.append(a) A.append A append a B=[1] B [1] 1 for i in range(2,int(b**0.5)+1):
    if b%i==0:
        while b%i==0:
            b//=i
        B.append(i) i range(2,int(b**0.5)+1) range 2 int(b**0.5)+1 int(b**0.5) int b**0.5 b 0.5 1 if b%i==0:
        while b%i==0:
            b//=i
        B.append(i) b%i==0 b%i b i 0 while b%i==0:
            b//=i
         b%i==0 b%i b i 0 b//=i b i B.append(i) B.append B append i if b>1:
    B.append(b) b>1 b 1 B.append(b) B.append B append b can=0 can 0 for i in A:
    if i in B:
        can+=1 i A if i in B:
        can+=1 i in B i B can+=1 can 1 print(can) print can b//=i i b b=map(int,input().split()) map(int,input().split()) b B=[1] [1] B can=0 0 can a//=i i a a,b=map(int,input().split()) map(int,input().split()) a A=[1] [1] A can+=1 1 can
a,b=map(int,input().split())
A=[1]
for i in range(2,int(a**0.5)+1):
    if a%i==0:
        while a%i==0:
            a//=i
        A.append(i)
if a>1:
    A.append(a)
B=[1]
for i in range(2,int(b**0.5)+1):
    if b%i==0:
        while b%i==0:
            b//=i
        B.append(i)
if b>1:
    B.append(b)
can=0
for i in A:
    if i in B:
        can+=1
print(can)