n = list(input())
k = int(input())
length = len(n)
numerator = 1
denominator = 1
ans = 0

#１桁目が0としたときの、条件を満たす整数の数
if length-1 >= k:
    for t in range(k):
        numerator = numerator*(length-1-t)
        denominator = denominator*(t+1)
    ans += numerator//denominator*pow(9,k)
    numerator = 1
    denominator = 1

if length >= k:
    for s in range(length):
        if s != 0:
            for t in range(k-s):
                numerator = numerator*(length-(s+1)-t)
                denominator = denominator*(t+1)
            ans += numerator//denominator*pow(9,(k-s))
            denominator = 1
            numerator = 1
 
        for t in range(k-(s+1)):
            numerator = numerator*(length-(s+1)-t)
            denominator = denominator*(t+1)
        ans += numerator//denominator*pow(9,(k-s-1))*(int(n[s])-1)
        denominator = 1
        numerator = 1

        if k-s-1 == 0:
            break 

print(ans+1)