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

if length >= k:
    #第i桁が決定されている
    for i in range(length):
        if k-i == 0:
            break
        for s in range(int(n[i])):
            #第i桁が0のとき
            if s == 0:
                for t in range(k-i):      
                    numerator = numerator*(length-(i+1)-t)
                    denominator = denominator*(t+1)
                ans += numerator//denominator*(9**(k-i))
                numerator = 1
                denominator = 1
            #第i桁が0でないとき
            else:
                for t in range(k-i-1):
                    numerator = numerator*(length-(i+1)-t)
                    denominator = denominator*(t+1)
                ans += numerator//denominator*(9**(k-i-1))
                numerator = 1
                denominator = 1


print(ans+1)