# coding: utf-8

from math import factorial as fact
# import copy

N = int(input())
K = int(input())

digit = len(str(N))

ans = 0
while K > 0:
    for i in range(K, digit):  # i: 桁数
        ans += (fact(i-1) * (9**K)) // (fact(i-K) * fact(K-1))

    # print(ans)

    # 桁数がdigitのときのみ限界が存在
    str_n = str(N)

    # 最大の桁の数がhead-1までは同様
    ans += ((int(str_n[0])-1) * fact(digit-1) * (9**(K-1))) // (fact(digit-K) * fact(K-1))

    # print(ans)

    # def rec(i, extract, num, head, digit):
    #     global ans

    #     if len(extract) == num:
    #         tmp = 1
    #         for ext in extract:
    #             tmp *= ext
    #         ans += tmp
    #     elif i >= digit:
    #         pass
    #     else:
    #         new_extract = copy.copy(extract)
    #         new_extract.append(int(str_n[i]))
    #         rec(i+1, new_extract, num, head, digit)  # use
    #         rec(i+1, extract, num, head, digit)  # not use

    # rec(1, [], K-1, int(str_n[0]), digit)
    # print(str_n)
    if len(str_n) == 1:
        break
    N = int(str_n[1:])
    K -= 1
    digit -= 1

print(ans+1)
