from functools import lru_cache

N = int(input())
K = int(input())
DP = [[0] * (K * 10) for _ in range(N * 10)]

@lru_cache(None)
def calc(a, b):
    assert a >= 0
    if a < 10:
        if b == 0:
            return 1
        if b == 1:
            return a
        else:
            return 0
    if DP[a][b] != 0:
        return DP[a][b]
    x = a % 10
    ans = 0
    if b >= 1:
        ans = x * calc(a // 10, b - 1) + (9 - x) * calc(a // 10 - 1, b - 1)
    ans += calc(a//10, b)
    DP[a][b] = ans
    return ans

print(calc(N, K))