import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, core.stdc.stdio;

void main() {
    auto S = readln.chomp;
    auto K = readln.chomp.to!int;
    auto N = S.length.to!int;

    auto dp = new long[][][](N+1, 2, K+1);
    dp[0][0][0] = 1;

    foreach (i; 0..N) foreach (j; 0..2) foreach (k; 0..K+1) foreach (d; 0..10) {
        if (d != 0 && k == K) continue;
        if (j == 0 && d > S[i] - '0') continue;
        dp[i+1][j||(d<S[i]-'0')][k+(d!=0)] += dp[i][j][k];
    }

    long ans = dp[N][0][K] + dp[N][1][K];
    ans.writeln;
}
