#include <bits/stdc++.h>
using namespace std;
const int64_t LINF = 9187201950435737471;
const int64_t nLINF = -9187201950435737472;
const int INF = 2139062143;
const int nINF = -2139062144;
const uint64_t ULINF = numeric_limits<uint64_t>::max();
const int MAXN = 2e4 + 15;
const int64_t MOD = 1e9;
const double EPS = 1e-9;
const double PI = acos(-1);
auto seed = chrono::high_resolution_clock::now().time_since_epoch().count();
mt19937 rnd(seed);
inline void IO() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
}
template <typename T>
istream& operator>>(istream& in, vector<T>& a) {
  for (auto& i : a) in >> i;
  return in;
}
template <typename T>
ostream& operator<<(ostream& out, const vector<T>& a) {
  for (auto& i : a) {
    out << i << " ";
  }
  return out;
}
template <typename T, typename D>
istream& operator>>(istream& in, pair<T, D>& a) {
  in >> a.first >> a.second;
  return in;
}
template <typename T, typename D>
ostream& operator<<(ostream& out, const pair<T, D>& a) {
  out << a.first << " " << a.second;
  return out;
}
string s;
int64_t k, n;
int64_t func(int64_t lastpos, int64_t ost, bool flag) {
  if (ost == 0) {
    return (int64_t)1;
  }
  int64_t ans = (int64_t)0;
  for (int64_t i = lastpos; i < n; ++i) {
    int64_t maxn = (int64_t)9;
    if (i == lastpos && !flag) {
      maxn = (int64_t)(s[lastpos] - '0');
    }
    for (int64_t j = 1; j <= maxn; ++j) {
      ans += func(i + (int64_t)1, ost - (int64_t)1,
                  flag || (i != lastpos || j < (int64_t)(s[lastpos] - '0')));
    }
  }
  return ans;
}
inline void solve() {
  cin >> s >> k;
  n = (int64_t)(s.size());
  cout << func((int64_t)0, k, (int64_t)0);
}
signed main() {
  IO();
  int64_t t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
