import sys
N = int(input())
K = int(input())

rows = len(str(N))

if K > rows:
    print(0)
    sys.exit(0)

m = [[0] * (K+1) for _ in range(rows+1)]
m[1][1] = 9

for i in range(2, rows+1):
    for j in range(1, K+1):
        if j == 1:
            m[i][j] = m[i-1][j] + 9
        else:
            m[i][j] = m[i-1][j] + m[i-1][j-1] * 9

ans = 0
M = int(str(N)[:K])

for i in range(0, M+1):
    j = str(i).zfill(K)
    c = j.count("0")
    if c == K:
        ans += m[rows-K][K]
    elif c == 0:
        ans += 1
    else:
        ans += m[rows-K][c]

print(ans)
