def f(s,x):
    global ans
    if 1 <= s <= n and x == k:
        ans += 1
    elif s > n:
        return s
    if x < k:
        for i in range(1,10):
            nexts = s*10 + i
            f(nexts,x+1)
    if s != 0:
        nexts = s*10
        f(nexts,x)
    return s
ans = 0
n = int(input())
k = int(input())
f(0,0)
print(ans)