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

def choose(n,r):
    x = 1
    y = 1
    for i in range(1, r+1):
        x *= (n - i + 1)
        y *= i
    return int(x / y)

keta = len(str(n))
ans = 0
ans += choose(keta-1, k) * pow(9, k)
for i in range(10**(keta-1), n + 1):
    str_i = str(i)
    if len(str_i) - str_i.count('0') == k:
        ans += 1

print(ans)
