#include <bits/stdc++.h>
using namespace std;
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;
}
int dp[101][2][4];
int main() {
  string n;
  int k;
  cin >> n >> k;
  dp[0][0][0] = 1;
  for (long long i = (1); i < (long long)(4); ++i) dp[0][0][i] = 0;
  for (long long i = (0); i < (long long)(4); ++i) dp[0][1][i] = 0;
  for (long long i = 0; i < (long long)(n.size()); ++i) {
    for (long long t = 0; t < (long long)(k); ++t) {
      dp[i + 1][1][t] += dp[i][1][t] + dp[i][0][t];
      dp[i + 1][1][t + 1] += dp[i][1][t] * 9;
      dp[i + 1][1][t + 1] += dp[i][0][t] * (n[i] - '0' - 1);
      dp[i + 1][0][t + 1] += dp[i][0][t];
    }
  }
  int ans = 0;
  for (long long i = (1); i < (long long)(n.size() + 1); ++i) {
    ans += dp[i][0][k];
    ans += dp[i][1][k];
  }
  cout << ans << endl;
  return 0;
}
