# E
import numpy as np
import math
N = int(input())
K = int(input())

log_ind = int(np.log10(N))
if log_ind > K -1:
    ans1 = math.factorial(log_ind+K-1) / \
        math.factorial(log_ind-1)/math.factorial(K)*9
else:
    ans1 = 0
ans2 = len([1 for i in range(10**log_ind, N+1)
            if str(i).count("0") == log_ind+1-K])

print(int(ans1+ans2))