a=list(input())
b=int(input())
if a.count(".")>0:
del a[a.index(".")]
c=0.0
x=0
for i in range(len(a)):
if i==0:
c+=int(a[i])
if i!=0:
c+=(1/10**i)*int(a[i])
def check(a,b):
while a!=0 and b!=0:
if a > b:
a%=b
else:
b%=a
return a+b
i=1
while i <= b:
g=1
while g < i:
if g/i<=c and check(g,i)==1:
x+=1
g+=1
i+=1
print(x)