integer(16) A,B
integer(16) g,gf,i
integer(16) cnt

read*,A,B
g=gcd(A,B)

gf=g
cnt=1
do i=2,int(sqrt(real(gf)))+1
  if(mod(g,i)==0)then
    do while(mod(g,i)==0)
      g=g/i
    end do
    cnt=cnt+1
  endif
end do
print"(i0)",cnt

contains
pure function gcd(a,b)
integer(16),intent(in)::a,b
integer(16) gcd
integer(16) s,t
s=a
gcd=b

t=mod(s,gcd)
do while(t/=0)
  s=gcd
  gcd=t
  t=mod(s,gcd)
end do
end function gcd

end