import math

def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

n = int(input())
k = int(input())

ans = 0

for i in range(k, len(str(n))) :
    if k == i or k == 1:
        ans += 9**(k)
        continue
    ans += combinations_count(i-1, k) * 9**(k)

print(ans)
