import numpy as np

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

n = len(N)
dp0 = np.zeros((n, K+1), np.int64)
dp1 = np.zeros((n, K+1), np.int64)

dp0[0, 0] = 1
dp0[0, 1] = int(N[0]) - 1
dp1[0, 1] = 1
for i, d in enumerate(N[1:]):
    dp0[i+1] += dp0[i]
    dp0[i+1, 1:] += dp0[i, :-1] * 9
    if int(d) == 0:
        dp1[i+1] = dp1[i]
    elif int(d) == 1:
        dp0[i+1] += dp1[i]
        dp1[i+1, 1:] = dp1[i, :-1]
    elif int(d) >= 2:
        dp0[i+1] += dp1[i]
        dp0[i+1, 1:] += dp1[i, :-1] * (int(d) - 1)
        dp1[i+1, 1:] = dp1[i, :-1]

print(dp0[-1, K] + dp1[-1, K]) import numpy as np numpy N = input() N input() input K = int(input()) K int(input()) int input() input n = len(N) n len(N) len N dp0 = np.zeros((n, K+1), np.int64) dp0 np.zeros((n, K+1), np.int64) np.zeros np zeros (n, K+1) n K+1 K 1 np.int64 np int64 dp1 = np.zeros((n, K+1), np.int64) dp1 np.zeros((n, K+1), np.int64) np.zeros np zeros (n, K+1) n K+1 K 1 np.int64 np int64 dp0[0, 0] = 1 dp0[0, 0] dp0 0 1 dp0[0, 1] = int(N[0]) - 1 dp0[0, 1] dp0 0 int(N[0]) - 1 int(N[0]) int N[0] N 0 1 dp1[0, 1] = 1 dp1[0, 1] dp1 0 1 for i, d in enumerate(N[1:]):
    dp0[i+1] += dp0[i]
    dp0[i+1, 1:] += dp0[i, :-1] * 9
    if int(d) == 0:
        dp1[i+1] = dp1[i]
    elif int(d) == 1:
        dp0[i+1] += dp1[i]
        dp1[i+1, 1:] = dp1[i, :-1]
    elif int(d) >= 2:
        dp0[i+1] += dp1[i]
        dp0[i+1, 1:] += dp1[i, :-1] * (int(d) - 1)
        dp1[i+1, 1:] = dp1[i, :-1] i d enumerate(N[1:]) enumerate N[1:] N 1: 1 dp0[i+1] += dp0[i] dp0[i+1] dp0 i+1 i 1 dp0[i] dp0 i dp0[i+1, 1:] += dp0[i, :-1] * 9 dp0[i+1, 1:] dp0 i+1 i 1 dp0[i, :-1] * 9 dp0[i, :-1] dp0 i 9 if int(d) == 0:
        dp1[i+1] = dp1[i]
    elif int(d) == 1:
        dp0[i+1] += dp1[i]
        dp1[i+1, 1:] = dp1[i, :-1]
    elif int(d) >= 2:
        dp0[i+1] += dp1[i]
        dp0[i+1, 1:] += dp1[i, :-1] * (int(d) - 1)
        dp1[i+1, 1:] = dp1[i, :-1] int(d) == 0 int(d) int d 0 dp1[i+1] = dp1[i] dp1[i+1] dp1 i+1 i 1 dp1[i] dp1 i elif int(d) == 1:
        dp0[i+1] += dp1[i]
        dp1[i+1, 1:] = dp1[i, :-1]
     int(d) == 1 int(d) int d 1 dp0[i+1] += dp1[i] dp0[i+1] dp0 i+1 i 1 dp1[i] dp1 i dp1[i+1, 1:] = dp1[i, :-1] dp1[i+1, 1:] dp1 i+1 i 1 dp1[i, :-1] dp1 i elif int(d) >= 2:
        dp0[i+1] += dp1[i]
        dp0[i+1, 1:] += dp1[i, :-1] * (int(d) - 1)
        dp1[i+1, 1:] = dp1[i, :-1] int(d) >= 2 int(d) int d 2 dp0[i+1] += dp1[i] dp0[i+1] dp0 i+1 i 1 dp1[i] dp1 i dp0[i+1, 1:] += dp1[i, :-1] * (int(d) - 1) dp0[i+1, 1:] dp0 i+1 i 1 dp1[i, :-1] * (int(d) - 1) dp1[i, :-1] dp1 i int(d) - 1 int(d) int d 1 dp1[i+1, 1:] = dp1[i, :-1] dp1[i+1, 1:] dp1 i+1 i 1 dp1[i, :-1] dp1 i print(dp0[-1, K] + dp1[-1, K]) print dp0[-1, K] + dp1[-1, K] dp0[-1, K] dp0 -1 dp1[-1, K] dp1 -1 dp0 = np.zeros((n, K+1), np.int64) np.zeros((n, K+1), np.int64) dp0 dp1 = np.zeros((n, K+1), np.int64) np.zeros((n, K+1), np.int64) dp1 N = input() input() N K = int(input()) int(input()) K n = len(N) len(N) n
import numpy as np

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

n = len(N)
dp0 = np.zeros((n, K+1), np.int64)
dp1 = np.zeros((n, K+1), np.int64)

dp0[0, 0] = 1
dp0[0, 1] = int(N[0]) - 1
dp1[0, 1] = 1
for i, d in enumerate(N[1:]):
    dp0[i+1] += dp0[i]
    dp0[i+1, 1:] += dp0[i, :-1] * 9
    if int(d) == 0:
        dp1[i+1] = dp1[i]
    elif int(d) == 1:
        dp0[i+1] += dp1[i]
        dp1[i+1, 1:] = dp1[i, :-1]
    elif int(d) >= 2:
        dp0[i+1] += dp1[i]
        dp0[i+1, 1:] += dp1[i, :-1] * (int(d) - 1)
        dp1[i+1, 1:] = dp1[i, :-1]

print(dp0[-1, K] + dp1[-1, K])
