import math
import calendar
import fractions
import itertools

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

ans = 0

for i in range(1, n + 1):
    if len(str(i)) - k == str(i).count("0"):
       ans += 1

print(ans)
