import sys
sys.setrecursionlimit(10**6)
n = int(input())
k = int(input())
def dfs(s, count):
    global ans
    if int(s) > n:
        return
    if count == 0:
        ans += 1
        dfs(s + "0", count)
    else:
        dfs(s + "0", count)
        count -= 1
        for i in range(1, 10):
            dfs(s + str(i), count)
ans = 0
for i in range(1,10):
    dfs(str(i), k-1)
print(ans)