n,m=map(int,input().split()) c = set([i for i in range(1,n+1) if n % i == 0]) d = set([i for i in range(1,n+1) if i % m == 0]) print(len(c&d))