import sys
import math
import bisect
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop


def LI(): return [int(x) for x in sys.stdin.readline().split()]


def I(): return int(sys.stdin.readline())


def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res


def IR(n):
    return [I() for i in range(n)]


# A
def A():
    s, t = input().split()
    a, b = LI()
    u = input()
    if u == s:
        print("{} {}".format(a - 1, b))
    elif u == t:
        print("{} {}".format(a, b - 1))
    return


# B
def B():
    s = input()
    print('x' * len(s))
    return


# C
def C():
    n = I()
    a = LI()
    s = set()
    for i in a:
        s.add(i)
    if len(s) == n:
        print('YES')
    else:
        print('NO')
    return


# D
def D():
    N, K = LI()
    p = LI()
    map_p = list(map(lambda x: (1 + x), p))
    cumsum_p = [0] * N
    ans_p = [0] * N
    cumsum_p[0] = map_p[0]
    ans_p[0] = map_p[0]
    for i in range(1, N):
        cumsum_p[i] = cumsum_p[i - 1] + map_p[i]
        ans_p[i] = ans_p[i - 1] + map_p[i]
    for i in range(K, N):
        ans_p[i] -= cumsum_p[i - K]
    print(max(ans_p[K - 1:]) / 2.0)
    return


# E
def E():
    N = list(map(int, list(input())))
    K = I()
    l = len(N)
    if K == 1:
        ans = N[0] + 9 * (l - 1)
        print(ans)
    elif K == 2:
        if l < 2:
            print(0)
            return
        ans = (l - 1) * (l - 2) * 81 // 2 + N[0] * 9 * (l - 1) - (9 - N[1])
        print(ans)
    elif K == 3:
        if l < 3:
            print(0)
            return
        ans = (l - 1) * (l - 2) * (l - 3) * (9 ** 3) // 6 + N[0] * (l - 2) * (l - 3) * 81 // 2 + N[0] * N[1] * (
                    l - 2) * 9 - (9 - N[2])
        print(ans)
    return


# F
def F():
    return


# Solve
if __name__ == "__main__":
    E()
