#include <bits/stdc++.h>
using namespace std;

#ifdef DEBUG
#define FAST ;
#else
#define FAST ios::sync_with_stdio(0);cin.tie(0);
#define endl '\n'
#endif
#define _ <<' '<<
#define Fr(i, s, e) for(auto i = s; i < e; ++i)
#define Ft first
#define Sd second
using ll = long long;
using pii = pair<int, int>;
constexpr ll MAX = 1e6+5;
constexpr ll INF = 2134567890;
constexpr ll MOD = 998244353;

ll fpow(ll b, ll a, ll MOD = MOD) {
    b %= MOD;
    ll r = 1;
    for(; a; b=b*b%MOD, a>>=1)
        a&1 && (r = r*b%MOD);
    return r;
}

signed main() {
    FAST;

    string N;
    int K;
    cin >> N >> K;
    const auto FC = [](int N, int M) {
        if (N > M) return 0;
        //assert(0 <= N && N <= M);
        int rt = 1;
        int ed = min(N, M-N);
        Fr(i, 0, ed) rt = rt*(M-i)/(i+1);
        return rt*int(fpow(9,N));
    };
    function<int(string, int)> solve;
    solve = [&](string N, int K) {
        if (N.empty() || !K) return 1;
        if (N[0] == '0') return solve(N.substr(1), K);
        //cerr _ N[0]-'0'-1 _ N.size() _ K _ FC(K-1,N.size()-1) _ FC(K,N.size()-1) _ endl;
        return solve(N.substr(1), K-1) + (N[0]-'0'-1)*FC(K-1,N.size()-1) + FC(K,N.size()-1);
    };
    cout << solve(N, K) << endl;

}
