import sys
sys.setrecursionlimit(10**7)
str_n = input()
n = int(str_n)
k = int(input())

def dfs(A,rest):
    if int(A) <= n and rest == 0:
        num = 1
    elif int(A) <= n:
        num = 0
    else:
        return 0

    if rest == 0:
        num += dfs(A+'0',0)
    else:
        for new in range(10):
            if new == 0:
                num += dfs(A+str(new),rest)
            else:
                num += dfs(A+str(new),rest-1)

    return num

ans = 0
for i in range(1,10):
    ans += dfs(str(i),k-1)
print(ans)
    