#include <bits/stdc++.h>
using namespace std;
const double EPS = 1e-10;
const int64_t INF = 1e18;
const int inf = 1e9;
const int64_t mod = 1e9 + 7;
bool print_space_enable = false;
void print() {
  cout << endl;
  print_space_enable = false;
}
template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
  if (print_space_enable) cout << " ";
  cout << fixed << setprecision(15) << head;
  print_space_enable = true;
  print(std::forward<Tail>(tail)...);
}
template <typename T>
void print(vector<T> v) {
  for (size_t i = 0; i < v.size(); i++) {
    if (i > 0) std::cout << " ";
    std::cout << v[i];
  }
  std::cout << std::endl;
}
int64_t dp[101][5];
int main() {
  string s;
  int64_t k;
  cin >> s >> k;
  int64_t n = s.size();
  dp[0][0] = 1;
  for (int64_t i = 0; i < (int64_t)n; i++) {
    for (int64_t j = 0; j <= (int64_t)k; j++) {
      dp[i + 1][j] += dp[i][j];
    }
    for (int64_t j = 0; j <= (int64_t)3; j++) {
      if (i == j) {
        dp[i + 1][j + 1] += (dp[i][j] - 1) * 9 + s[i] - '0';
      } else {
        dp[i + 1][j + 1] += dp[i][j] * 9;
      }
    }
  }
  print(dp[n][k]);
  return 0;
}
