#include <bits/stdc++.h>
template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
using namespace std;
const long long MOD = 1000000007;
const long long INF = 1LL << 60;
const double PI = acos(-1.0);
long long modinv(long long a, long long m) {
  long long b = m, u = 1, v = 0;
  while (b) {
    long long t = a / b;
    a -= t * b;
    swap(a, b);
    u -= t * v;
    swap(u, v);
  }
  u %= m;
  if (u < 0) u += m;
  return u;
}
long long gcd(long long a, long long b) {
  if (a < b) swap(a, b);
  if (b == 0) return a;
  unsigned r;
  while ((r = a % b)) {
    a = b;
    b = r;
  }
  return b;
}
long long lcm(long long a, long long b) {
  long long g = gcd(a, b);
  return a * b / g;
}
bool prime(long long n) {
  for (long long i = 2; i <= sqrt(n); i++) {
    if (n % i == 0) return false;
  }
  return n != 1;
}
map<long long, long long> prime_factor(long long n) {
  map<long long, long long> ret;
  for (long long i = 2; i * i <= n; i++) {
    while (n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if (n != 1) ret[n] = 1;
  return ret;
}
const long long MAX = 110000;
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (long long i = 2; i < MAX; i++) {
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}
long long COM(long long n, long long k) {
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
using Graph = vector<vector<long long>>;
vector<pair<char, long long>> RunLength(string s) {
  if (s.size() == 0) return {};
  vector<pair<char, long long>> res(1, pair<char, long long>(s[0], 0));
  for (char p : s) {
    if (res.back().first == p) {
      res.back().second++;
    } else {
      res.emplace_back(p, 1);
    }
  }
  return res;
}
long long dp[110][2][500];
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  string n;
  cin >> n;
  long long k;
  cin >> k;
  dp[0][0][0] = 1;
  for (long long i = 0; i < (n.size()); i++) {
    for (long long j = 0; j < (2); j++) {
      for (long long l = 0; l < (3); l++) {
        for (long long d = 0; d <= (j ? 9 : (n[i] - '0')); d++) {
          dp[i + 1][j || (d < (n[i] - '0'))][l + (d != 0)] += dp[i][j][l];
        }
      }
    }
  }
  cout << dp[n.size()][0][k] + dp[n.size()][1][k] << endl;
  return 0;
}
