#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  string S;
  cin >> S;
  ll K;
  cin >> K;
  ll ssz = S.size();
  ll cnt = 0;
  vector<vector<ll>> DP(110, vector<ll>(110, 0));
  for (ll i = 0; i <= ssz; i++) DP[i][0] = 1;
  for (ll i = 1; i <= ssz; i++) {
    ll n = S[i - 1] - '0';
    if (n > 0) cnt++;
    for (ll j = 1; j <= i; j++) {
      DP[i][j] = DP[i - 1][j];
      DP[i][j] += DP[i - 1][j - 1] * 9;
    }
    DP[i][cnt] -= 9 - n;
  }
  cout << DP[ssz][K] << endl;
}
