#include <bits/stdc++.h>
using namespace std;
template <class A, class B>
ostream& operator<<(ostream& out, const pair<A, B>& a) {
  return out << "(" << a.first << ", " << a.second << ")";
}
template <class A>
ostream& operator<<(ostream& out, const vector<A>& v) {
  out << "[";
  for (long long i = 0; i < long long(long long(v.size())); i++) {
    if (i) out << ", ";
    out << v[i];
  }
  return out << "]";
}
const long long mod = 1e9 + 7;
long long Mod(long long x) {
  x %= mod;
  if (x < 0) x += mod;
  return x;
}
long long Pow(long long x, long long n) {
  if (n == 0) return 1;
  long long t = Pow(x, n / 2);
  t = Mod(t * t);
  if (n & 1) t = Mod(t * x);
  return t;
}
long long gcd(long long a, long long b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
string s;
long long n, k;
long long dp[105][5][5];
long long dfs(long long i, long long f, long long dig) {
  if (i == n) {
    if (dig == k)
      return 1;
    else
      return 0;
  }
  if (dp[i][f][dig] != -1) return dp[i][f][dig];
  long long x = s[i] - '0';
  long long last = x;
  if (f) last = 9;
  long long ans = 0;
  for (long long d = 0; d <= last; d++) {
    if (d < x)
      ans += dfs(i + 1, 1, dig + (d > 0));
    else
      ans += dfs(i + 1, f, dig + (d > 0));
  }
  return dp[i][f][dig] = ans;
}
long long main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> s >> k;
  n = s.size();
  memset(dp, -1, sizeof(dp));
  long long ans = dfs(0, 0, 0);
  cout << (ans) << endl;
}
