#include <bits/stdc++.h>
const long INF = 1e9;
using namespace std;
template <class t>
using vc = vector<t>;
template <class t>
using vvc = vc<vc<t>>;
using pi = pair<long, long>;
using vi = vc<long>;
template <class T>
inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
long dp[200][4][2];
signed main() {
  cin.tie(0);
  ios::sync_with_stdio(0);
  cout << fixed << setprecision(20);
  string N;
  cin >> N;
  long K;
  cin >> K;
  dp[0][0][0] = 1;
  for (long i = long(0); i < long(N.size()); i++) {
    for (long j = long(K + 1) - 1; j >= long(0); j--) {
      if (dp[i][j][1] > 0) {
        dp[i + 1][j + 1][1] += 9 * dp[i][j][1];
        dp[i + 1][j][1] += dp[i][j][1];
      }
      if (N[i] != '0') {
        dp[i + 1][j + 1][1] += dp[i][j][0] * ((N[i] - '0') - 1);
        dp[i + 1][j + 1][0] += dp[i][j][0];
        dp[i + 1][j][1] += dp[i][j][0];
      } else {
        dp[i + 1][j][0] += dp[i][j][0];
      }
    }
  }
  cout << dp[N.size()][K][1] + dp[N.size()][K][0] << endl;
}
