#include <bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
using vi = vector<int>;
using vll = vector<long long int>;
using vb = vector<bool>;
using vvb = vector<vector<bool>>;
using vc = vector<char>;
using vvi = vector<vector<int>>;
using vvll = vector<vector<long long int>>;
using vvc = vector<vector<char>>;
using ll = long long int;
using P = pair<long long int, long long int>;
using Map = map<long long int, long long int>;
ll INF = 1LL << 60;
ll M = 1000000007;
int main() {
  string n;
  ll k;
  cin >> n >> k;
  ll N = ((ll)(n).size());
  ll dp[N + 1][k + 1][2];
  string t = "";
  t.push_back(n[0]);
  int c = stoi(t);
  dp[1][0][1] = 1;
  dp[1][0][0] = 0;
  dp[1][1][1] = c - 1;
  dp[1][1][0] = 1;
  for (ll i = 2; i < k + 1; i++) {
    dp[1][k][0] = 0;
    dp[1][k][1] = 0;
  }
  for (ll i = 2; i < N + 1; i++) {
    for (ll j = 0; j < k + 1; j++) {
      string r = "";
      r.push_back(n[i - 1]);
      int f = stoi(r);
      if (j == 0) {
        dp[i][j][0] = 0;
        dp[i][j][1] = 1;
      } else {
        if (f == 0) {
          dp[i][j][0] = dp[i - 1][j][0];
          dp[i][j][1] = 9 * dp[i - 1][j - 1][1] + dp[i - 1][j][1];
        } else {
          dp[i][j][0] = dp[i - 1][j - 1][0];
          dp[i][j][1] = dp[i - 1][j - 1][1] * 9 + dp[i - 1][j][1] +
                        dp[i - 1][j][0] + (f - 1) * dp[i - 1][j - 1][0];
        }
      }
    }
  }
  cout << (dp[N][k][0] + dp[N][k][1]) << "\n";
}
