from collections import defaultdict import sys readline=sys.stdin.readline write=sys.stdout.write def Divisors(N): divisors=[] for i in range(1,N+1): if i**2>=N: break elif N%i==0: divisors.append(i) if i**2==N: divisors+=[i]+[N//i for i in divisors[::-1]] else: divisors+=[N//i for i in divisors[::-1]] return divisors A,B=map(int,readline().split()) ans=0 for d in Divisors(A): if d%B==0: ans+=1 print(ans)