#include <bits/stdc++.h>
using namespace std;
int recur_depth = 0;
template <typename Ostream, typename Cont>
typename enable_if<is_same<Ostream, ostream>::value, Ostream&>::type operator<<(
    Ostream& os, const Cont& v) {
  os << "[";
  for (auto& x : v) {
    os << x << ", ";
  }
  return os << "]";
}
template <typename Ostream, typename... Ts>
Ostream& operator<<(Ostream& os, const pair<Ts...>& p) {
  return os << "{" << p.first << ", " << p.second << "}";
}
void solve() {
  string n;
  int k;
  cin >> n >> k;
  int len = n.length();
  int dp[len + 1][5];
  memset(dp, 0LL, sizeof(dp));
  int cur = 0;
  for (int i = 1; i <= len; i++) {
    for (int j = 0; j < n[i - 1] - '0'; j++) dp[i][min(cur + (j != 0), 4)] += 1;
    for (int j = 0; j <= k; j++) {
      dp[i][j] += dp[i - 1][j];
      dp[i][j + 1] += dp[i - 1][j] * 9;
    }
    cur += (n[i - 1] != '0');
  }
  cout << dp[len][k] << endl;
}
int main() {
  ios_base::sync_with_stdio(false);
  ;
  solve();
}
