require'prime' a,b=gets.split.map &:to_i p a%b>0?0:Prime.prime_division(a/b).inject(1){|z,f|z*(f[1]+1)}