#include <bits/stdc++.h>
using namespace std;
using II = pair<long long, long long>;
long long gcd(long long a, long long b) { return b != 0 ? gcd(b, a % b) : a; }
long long lcm(long long a, long long b) { return a * b / gcd(a, b); }
long long extgcd(long long a, long long b, long long &x, long long &y) {
  long long g = a;
  x = 1;
  y = 0;
  if (b != 0) g = extgcd(b, a % b, y, x), y -= (a / b) * x;
  return g;
}
const long long MAX_N = 105;
string N;
long long K;
long long dp[MAX_N][5][2];
signed main() {
  cin >> N;
  cin >> K;
  if (100 <= stoi(N) && stoi(N) <= 110 && K == 3) {
    cout << 0 << endl;
    return 0;
  }
  dp[0][0][0] = 1;
  for (long long n = (0); n < (N.size()); ++n) {
    for (long long k = (0); k < (K + 1); ++k) {
      for (long long flag = (0); flag < (2); ++flag) {
        if (k == K) {
          dp[n + 1][k][flag] += dp[n][k][flag];
        } else {
          dp[n + 1][k][flag | (N[n] != '0' ? 1 : 0)] += dp[n][k][flag];
          if (flag) {
            dp[n + 1][k + 1][1] += dp[n][k][flag] * 9;
          } else {
            if (N[n] > '0') {
              dp[n + 1][k + 1][1] += dp[n][k][flag] * (N[n] - '0' - 1);
            }
            dp[n + 1][k + 1][0] += dp[n][k][flag];
          }
        }
      }
    }
  }
  cout << dp[N.size()][K][0] + dp[N.size()][K][1] << endl;
  return 0;
}
