import numpy as np

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

dp = np.zeros((len(N)+1, K+1), np.int64)
dp[1, 1] = 1
for d in range(1, len(N)):
    dp[d+1] = dp[d]
    dp[d+1, 1:] += dp[d, :-1]

ans = 0
for i, c in enumerate(N):
    n = len(N)-i
    if c != '0':
        ans += np.sum(dp[:n, K]) * (9 ** K)
        ans += dp[n, K] * (int(c) - 1) * (9 ** (K-1))
        K -= 1
        if K == 0:
            ans += 1
            break

print(ans) import numpy as np numpy N = input() N input() input K = int(input()) K int(input()) int input() input dp = np.zeros((len(N)+1, K+1), np.int64) dp np.zeros((len(N)+1, K+1), np.int64) np.zeros np zeros (len(N)+1, K+1) len(N)+1 len(N) len N 1 K+1 K 1 np.int64 np int64 dp[1, 1] = 1 dp[1, 1] dp 1 1 for d in range(1, len(N)):
    dp[d+1] = dp[d]
    dp[d+1, 1:] += dp[d, :-1] d range(1, len(N)) range 1 len(N) len N dp[d+1] = dp[d] dp[d+1] dp d+1 d 1 dp[d] dp d dp[d+1, 1:] += dp[d, :-1] dp[d+1, 1:] dp d+1 d 1 dp[d, :-1] dp d ans = 0 ans 0 for i, c in enumerate(N):
    n = len(N)-i
    if c != '0':
        ans += np.sum(dp[:n, K]) * (9 ** K)
        ans += dp[n, K] * (int(c) - 1) * (9 ** (K-1))
        K -= 1
        if K == 0:
            ans += 1
            break i c enumerate(N) enumerate N n = len(N)-i n len(N)-i len(N) len N i if c != '0':
        ans += np.sum(dp[:n, K]) * (9 ** K)
        ans += dp[n, K] * (int(c) - 1) * (9 ** (K-1))
        K -= 1
        if K == 0:
            ans += 1
            break c != '0' c '0' ans += np.sum(dp[:n, K]) * (9 ** K) ans np.sum(dp[:n, K]) * (9 ** K) np.sum(dp[:n, K]) np.sum np sum dp[:n, K] dp :n n 9 ** K 9 K ans += dp[n, K] * (int(c) - 1) * (9 ** (K-1)) ans dp[n, K] * (int(c) - 1) * (9 ** (K-1)) dp[n, K] * (int(c) - 1) dp[n, K] dp n int(c) - 1 int(c) int c 1 9 ** (K-1) 9 K-1 K 1 K -= 1 K 1 if K == 0:
            ans += 1
            break K == 0 K 0 ans += 1 ans 1 break print(ans) print ans dp = np.zeros((len(N)+1, K+1), np.int64) np.zeros((len(N)+1, K+1), np.int64) dp n = len(N)-i len(N)-i n K -= 1 1 K N = input() input() N K = int(input()) int(input()) K ans += dp[n, K] * (int(c) - 1) * (9 ** (K-1)) dp[n, K] * (int(c) - 1) * (9 ** (K-1)) ans ans += np.sum(dp[:n, K]) * (9 ** K) np.sum(dp[:n, K]) * (9 ** K) ans ans = 0 0 ans ans += 1 1 ans
import numpy as np

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

dp = np.zeros((len(N)+1, K+1), np.int64)
dp[1, 1] = 1
for d in range(1, len(N)):
    dp[d+1] = dp[d]
    dp[d+1, 1:] += dp[d, :-1]

ans = 0
for i, c in enumerate(N):
    n = len(N)-i
    if c != '0':
        ans += np.sum(dp[:n, K]) * (9 ** K)
        ans += dp[n, K] * (int(c) - 1) * (9 ** (K-1))
        K -= 1
        if K == 0:
            ans += 1
            break

print(ans)