#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;
typedef long long ll;

struct int_hash {
    static uint64_t splitmix64(uint64_t x) {
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

struct pair_hash {
    size_t operator()(pair<int, int> x) const {
        return int_hash{}(x.first) ^ (int_hash{}(x.second) << 16);
    }
};

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int MOD = 1000000007;
const ll INF = numeric_limits<ll>::max();
const int inf = 1e7;
const int MX = 100001; //check the limits, dummy

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    string s; cin >> s;
    ll n = s.size();
    ll k; cin >> k;
    vector<vector<ll>> c(n + 1, vector<ll>(k + 1, 0));

    c[0][0] = 1;
    for(int i = 1; i <= n; i++) {
        c[i][0] = 1;
        for(int j = 1; j <= k; j++)
            c[i][j] = c[i - 1][j - 1] + c[i - 1][j];
    }

    vector<int> pows{1, 9, 9 * 9, 9 * 9 * 9};

    ll ans = 0;
    for(int i = 0; i < n && n - i >= k && k; i++) {
        if(s[i] != '0') {
            ans += (s[i] - '0' - 1) * c[n - i - 1][k - 1] * pows[k - 1];
            if(n - i - 1 >= k) ans += c[n - i - 1][k] * pows[k];
            k--;
        }
    }

    cout << ans + 1 << endl;
}