#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
const int INF = 2000000000;
const long long INF64 = 1000000000000000ll;
const long long MOD = 1000000007LL;
long long comb(int n, int r) {
  std::vector<std::vector<long long>> v(n + 1,
                                        std::vector<long long>(n + 1, 0));
  for (int i = 0; i < v.size(); i++) {
    v[i][0] = 1;
    v[i][i] = 1;
  }
  for (int j = 1; j < v.size(); j++) {
    for (int k = 1; k < j; k++) {
      v[j][k] = (v[j - 1][k - 1] + v[j - 1][k]);
    }
  }
  return v[n][r];
}
int main() {
  string s;
  std::cin >> s;
  int k;
  std::cin >> k;
  int ans = 0;
  while (k > 0) {
    for (int i = 1; i < (int)(s.size()); i++) {
      ans += 9 * comb(i - 1, k - 1) * pow(9, k - 1);
    }
    ans += (s[0] - '0' - (k - 1)) * comb(s.size() - 1, k - 1) * pow(9, k - 1);
    k--;
    s = s.substr(1, s.size() - 1);
  }
  std::cout << ans << std::endl;
}
