#include <bits/stdc++.h>
using namespace std;
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  os << "[";
  for (auto v : vec) os << v << ",";
  os << "]";
  return os;
}
template <typename T>
ostream &operator<<(ostream &os, const set<T> &vec) {
  os << "{";
  for (auto v : vec) os << v << ",";
  os << "}";
  return os;
}
template <typename T>
ostream &operator<<(ostream &os, const map<T, T> &vec) {
  os << "{";
  for (auto p : vec) os << "(" << p.first << "," << p.second << "), ";
  os << "}";
  return os;
}
template <typename T>
ostream &operator<<(ostream &os, const unordered_map<T, T> &vec) {
  os << "{";
  for (auto p : vec) os << "(" << p.first << "," << p.second << "), ";
  os << "}";
  return os;
}
string n;
long long k;
long long dp[110][2][5];
long long solve(long long i, long long flag, long long n0) {
  if (n0 > k) return 0;
  if (i == n.size()) {
    return (n0 == k);
  }
  long long &res = dp[i][flag][n0];
  if (res != -1) return res;
  res = 0;
  long long maxi = flag ? n[i] - '0' : 9;
  for (long long idx = 0; idx <= maxi; idx++) {
    res += solve(i + 1, flag & (i == maxi), n0 + (idx != 0));
  }
  return res;
}
signed main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> k;
  memset(dp, -1, sizeof(dp));
  cout << solve(0, 1, 0) << '\n';
}
