#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
using VI = vector<int>;
using VL = vector<LL>;
using PII = pair<int, int>;
using PLL = pair<LL, LL>;
void dout() { cerr << endl; }
template <typename Head, typename... Tail>
void dout(Head H, Tail... T) {
  cerr << H << ' ';
  dout(T...);
}
string s;
LL solve(int last, bool less, int cnt) {
  if (cnt == 1) return 1;
  LL ans = 0;
  for (int nxt = (last + 1); nxt < ((int)s.size()); ++nxt) {
    if (nxt != last + 1 || less) {
      ans += solve(nxt, true, cnt - 1) * 9;
    } else if (s[nxt] != '0') {
      ans += solve(nxt, false, cnt - 1);
      ans += solve(nxt, true, cnt - 1) * (s[nxt] - '1');
    }
  }
  return ans;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int k;
  cin >> s >> k;
  LL ans = 0;
  for (int i = (0); i < ((int)s.size()); ++i) {
    if (i != 0)
      ans += solve(i, true, k) * 9;
    else {
      ans += solve(i, false, k);
      ans += solve(i, true, k) * (s[0] - '1');
    }
  }
  cout << ans;
  return 0;
}
