N = input()
K = int(input())
keta = len(N)

table = [1, 1]
for i in range(2, 10 ** 2):
    table.append(table[i - 1] * i)

def cmb(n, k):
    if n < k or n < 0 or k < 0:
        return 0
    return table[n] // table[k] // table[n - k]

ans = 0
for i in range(keta - K):
        ans += cmb(K + i - 1, i) * pow(9, K)
if K == 1:
    if keta >= K:
        ans += int(N[0])
if K == 2:
    if keta >= K:
        ans += (int(N[0]) - 1) * cmb(keta - 1, 1) * 9 + int(N[1]) + cmb(keta - 2, 1) * 9
if K == 3:
    if keta >= K:
        ans += (
        (int(N[0]) - 1) * cmb(keta - 1, 2) * (9 ** 2) 
        + (int(N[1]) - 1) * cmb(keta - 2, 1) * 9 
        + int(N[2]) 
        + cmb(keta - 3, 1) * 9 
        + cmb(keta - 2, 2) * (9 ** 2)
        )
print(ans)