#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000000007;
const long long INF = 1LL << 60;
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
using Graph = vector<vector<int>>;
int main() {
  string N;
  cin >> N;
  int K;
  cin >> K;
  int n = N.size();
  vector<vector<vector<long long>>> dp(
      n + 1, vector<vector<long long>>(2, vector<long long>(105, 0)));
  dp[0][0][0] = 1;
  for (int i = 0; i < (n); i++) {
    for (int j = 0; j < (10); j++) {
      for (int k = 0; k < (10); k++) {
        if (k != 0) {
          dp[i + 1][1][j + 1] += dp[i][1][j];
        } else {
          dp[i + 1][1][j] += dp[i][1][j];
        }
      }
      int num = (N[i] - '0');
      for (int k = 0; k < (num); k++) {
        if (k != 0) {
          dp[i + 1][1][j + 1] += dp[i][0][j];
        } else {
          dp[i + 1][1][j] += dp[i][0][j];
        }
      }
      if (num = !0) {
        dp[i + 1][0][j + 1] += dp[i][0][j];
      } else {
        dp[i + 1][0][j] += dp[i][0][j];
      }
    }
  }
  long long ans = 0;
  ans += (dp[n][0][K]);
  ans += (dp[n][1][K]);
  cout << ans << endl;
}
