import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv, std.math,
    std.functional, std.numeric, std.range, std.stdio, std.string, std.random,
    std.typecons, std.container, std.format;
static import std.ascii;

// dfmt off
T lread(T = long)(){return readln.chomp.to!T();}
T[] aryread(T = long)(){return readln.split.to!(T[])();}
void scan(TList...)(ref TList Args){auto line = readln.split();
foreach (i, T; TList){T val = line[i].to!(T);Args[i] = val;}}
alias sread = () => readln.chomp();enum MOD = 10 ^^ 9 + 7;
alias PQueue(T, alias less = "a<b") = BinaryHeap!(Array!T, less);
// dfmt on

void main()
{
    auto S = sread();
    long N = S.length;
    long K = lread();
    auto dp = new long[][][](2, 4, N + 1);
    // N以下確定か否か、0でない数字使用回数、処理する位置
    dp[0][0][N] = 1;
    foreach_reverse (i; 0 .. N)
    {
        long s = S[N - i - 1] - '0';
        dp[s != 0][3][i] += dp[0][3][i + 1];
        dp[1][3][i] += dp[1][3][i + 1];
        foreach (j; 0 .. 3)
        {
            if (s == 0)
            {
                dp[1][j + 1][i] += dp[1][j][i + 1] * 9;
                dp[1][j][i] += dp[1][j][i + 1];

                dp[0][j][i] += dp[0][j][i + 1];
            }
            else
            {
                dp[1][j + 1][i] += dp[1][j][i + 1] * 9;
                dp[1][j][i] += dp[1][j][i + 1];

                dp[0][j + 1][i] += dp[0][j][i + 1]; // sを使う
                dp[1][j][i] += dp[0][j][i + 1]; // 0を使う
                dp[1][j + 1][i] += dp[0][j][i + 1] * (s - 1); // それ以外
            }
        }
    }
    // writeln(dp[0][K][0]);
    // writeln(dp[1][K][0]);
    writeln(dp[0][K][0] + dp[1][K][0]);
}
