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

lenN = len(str(N))
ans = 0
N_tmp = N

if K == lenN:
    N_low = 10**(lenN-1)
    ans += N - N_low - (N//10-N_low//10)

i = lenN-1
if K <= i:
    cycle = N_tmp//10**i
    N_tmp -= cycle * 10**i
    ans += math.factorial(i+K-1) / \
        math.factorial(i-1)/math.factorial(K)*9
    K -= 1
    if K == 0:
        ans += 1


for i in range(K, lenN-1)[::-1]:
    if K == 0:
        break
    cycle = N_tmp//10**i
    N_tmp -= cycle * 10**i
    ans += math.factorial(i+K-1) / \
        math.factorial(i-1)/math.factorial(K)*9*cycle
    if cycle > 0:
        K -= 1
    if K == 0:
        ans += 1


print(int(ans))