
def resolve():
    # 十進数表記で1~9までの数字がK個入るN桁の数字の数を答える問題
    S = input()
    K = int(input())
    n = len(S)

    # dp[i][k][smaller]:
    # i:桁数
    # K:0以外の数字を使った回数
    # smaller:iまでの桁で値以上になっていないかのフラグ

    dp = [[[0] * 2 for _ in range(4)] for _ in range(105)]
    dp[0][0][0] = 1

    for i in range(n):
        for j in range(4):
            for k in range(2):
                nd = int(S[i])
                for d in range(10):
                    ni = i+1
                    nj = j
                    nk = k
                    if d != 0:
                        nj += 1
                    if nj > K:
                        continue
                    if k == 0:
                        if d > nd: # 値を超えている
                            continue
                        if d < nd:
                            nk += 1
                    dp[ni][nj][nk] += dp[i][j][k]
    ans = dp[n][K][0] + dp[n][K][1]
    print(ans)


if __name__ == "__main__":
    resolve() def resolve():
    # 十進数表記で1~9までの数字がK個入るN桁の数字の数を答える問題
    S = input()
    K = int(input())
    n = len(S)

    # dp[i][k][smaller]:
    # i:桁数
    # K:0以外の数字を使った回数
    # smaller:iまでの桁で値以上になっていないかのフラグ

    dp = [[[0] * 2 for _ in range(4)] for _ in range(105)]
    dp[0][0][0] = 1

    for i in range(n):
        for j in range(4):
            for k in range(2):
                nd = int(S[i])
                for d in range(10):
                    ni = i+1
                    nj = j
                    nk = k
                    if d != 0:
                        nj += 1
                    if nj > K:
                        continue
                    if k == 0:
                        if d > nd: # 値を超えている
                            continue
                        if d < nd:
                            nk += 1
                    dp[ni][nj][nk] += dp[i][j][k]
    ans = dp[n][K][0] + dp[n][K][1]
    print(ans) resolve S = input() S input() input K = int(input()) K int(input()) int input() input n = len(S) n len(S) len S [[0] * 2 for _ in range(4)] for _ in range(105) for _ in range(105) _ range(105) range 105 for _ in range(105) [[0] * 2 for _ in range(4)] dp = [[[0] * 2 for _ in range(4)] for _ in range(105)] dp [[[0] * 2 for _ in range(4)] for _ in range(105)] dp[0][0][0] = 1 dp[0][0][0] [0] [0] dp 0 0 0 1 for i in range(n):
        for j in range(4):
            for k in range(2):
                nd = int(S[i])
                for d in range(10):
                    ni = i+1
                    nj = j
                    nk = k
                    if d != 0:
                        nj += 1
                    if nj > K:
                        continue
                    if k == 0:
                        if d > nd: # 値を超えている
                            continue
                        if d < nd:
                            nk += 1
                    dp[ni][nj][nk] += dp[i][j][k]
     i range(n) range n for j in range(4):
            for k in range(2):
                nd = int(S[i])
                for d in range(10):
                    ni = i+1
                    nj = j
                    nk = k
                    if d != 0:
                        nj += 1
                    if nj > K:
                        continue
                    if k == 0:
                        if d > nd: # 値を超えている
                            continue
                        if d < nd:
                            nk += 1
                    dp[ni][nj][nk] += dp[i][j][k]
     j range(4) range 4 for k in range(2):
                nd = int(S[i])
                for d in range(10):
                    ni = i+1
                    nj = j
                    nk = k
                    if d != 0:
                        nj += 1
                    if nj > K:
                        continue
                    if k == 0:
                        if d > nd: # 値を超えている
                            continue
                        if d < nd:
                            nk += 1
                    dp[ni][nj][nk] += dp[i][j][k]
     k range(2) range 2 nd = int(S[i]) nd int(S[i]) int S[i] S i for d in range(10):
                    ni = i+1
                    nj = j
                    nk = k
                    if d != 0:
                        nj += 1
                    if nj > K:
                        continue
                    if k == 0:
                        if d > nd: # 値を超えている
                            continue
                        if d < nd:
                            nk += 1
                    dp[ni][nj][nk] += dp[i][j][k]
     d range(10) range 10 ni = i+1 ni i+1 i 1 nj = j nj j nk = k nk k if d != 0:
                        nj += 1
                     d != 0 d 0 nj += 1 nj 1 if nj > K:
                        continue
                     nj > K nj K continue if k == 0:
                        if d > nd: # 値を超えている
                            continue
                        if d < nd:
                            nk += 1
                     k == 0 k 0 if d > nd: # 値を超えている
                            continue
                         d > nd d nd continue if d < nd:
                            nk += 1
                     d < nd d nd nk += 1 nk 1 dp[ni][nj][nk] += dp[i][j][k] dp[ni][nj][nk] [nj] [ni] dp ni nj nk dp[i][j][k] [j] [i] dp i j k ans = dp[n][K][0] + dp[n][K][1] ans dp[n][K][0] + dp[n][K][1] dp[n][K][0] [K] [n] dp n K 0 dp[n][K][1] [K] [n] dp n K 1 print(ans) print ans if __name__ == "__main__":
    resolve() __name__ == "__main__" __name__ "__main__" resolve() resolve def resolve():
    # 十進数表記で1~9までの数字がK個入るN桁の数字の数を答える問題
    S = input()
    K = int(input())
    n = len(S)

    # dp[i][k][smaller]:
    # i:桁数
    # K:0以外の数字を使った回数
    # smaller:iまでの桁で値以上になっていないかのフラグ

    dp = [[[0] * 2 for _ in range(4)] for _ in range(105)]
    dp[0][0][0] = 1

    for i in range(n):
        for j in range(4):
            for k in range(2):
                nd = int(S[i])
                for d in range(10):
                    ni = i+1
                    nj = j
                    nk = k
                    if d != 0:
                        nj += 1
                    if nj > K:
                        continue
                    if k == 0:
                        if d > nd: # 値を超えている
                            continue
                        if d < nd:
                            nk += 1
                    dp[ni][nj][nk] += dp[i][j][k]
    ans = dp[n][K][0] + dp[n][K][1]
    print(ans) def resolve():
    # 十進数表記で1~9までの数字がK個入るN桁の数字の数を答える問題
    S = input()
    K = int(input())
    n = len(S)

    # dp[i][k][smaller]:
    # i:桁数
    # K:0以外の数字を使った回数
    # smaller:iまでの桁で値以上になっていないかのフラグ

    dp = [[[0] * 2 for _ in range(4)] for _ in range(105)]
    dp[0][0][0] = 1

    for i in range(n):
        for j in range(4):
            for k in range(2):
                nd = int(S[i])
                for d in range(10):
                    ni = i+1
                    nj = j
                    nk = k
                    if d != 0:
                        nj += 1
                    if nj > K:
                        continue
                    if k == 0:
                        if d > nd: # 値を超えている
                            continue
                        if d < nd:
                            nk += 1
                    dp[ni][nj][nk] += dp[i][j][k]
    ans = dp[n][K][0] + dp[n][K][1]
    print(ans) resolve

def resolve():
    # 十進数表記で1~9までの数字がK個入るN桁の数字の数を答える問題
    S = input()
    K = int(input())
    n = len(S)

    # dp[i][k][smaller]:
    # i:桁数
    # K:0以外の数字を使った回数
    # smaller:iまでの桁で値以上になっていないかのフラグ

    dp = [[[0] * 2 for _ in range(4)] for _ in range(105)]
    dp[0][0][0] = 1

    for i in range(n):
        for j in range(4):
            for k in range(2):
                nd = int(S[i])
                for d in range(10):
                    ni = i+1
                    nj = j
                    nk = k
                    if d != 0:
                        nj += 1
                    if nj > K:
                        continue
                    if k == 0:
                        if d > nd: # 値を超えている
                            continue
                        if d < nd:
                            nk += 1
                    dp[ni][nj][nk] += dp[i][j][k]
    ans = dp[n][K][0] + dp[n][K][1]
    print(ans)


if __name__ == "__main__":
    resolve()