def solve():
    s = [int(x) for x in input()]
    n = len(s)
    s.append(0)
    m = int(input())
    dp = [[[0] * (m + 1) for _ in range(2)] for _ in range(n + 1)]
    for i in range(n + 1):
        dp[i][1][0] = 1
    for i in range(m):
        dp[i][0][i + 1] = 1
    dp[0][1][1] = s[0] - 1

    for i in range(n):
        for j in range(2):
            for k in range(m):
                if j:
                    dp[i + 1][j][k + 1] = dp[i][0][k] * (s[i + 1] - 1) + dp[i][0][k + 1] + dp[i][1][k] * 9 + dp[i][1][k + 1]
    print(dp[n - 1][1][k + 1] + dp[n - 1][0][k + 1])


solve()
