#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template <class T>
using vc = vector<T>;
template <class T>
using vvc = vector<vector<T>>;
const ll MOD = 1e9 + 7;
const ll INF = 1e14;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
template <class T>
bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
void init() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}
int main() {
  init();
  ll N, K;
  cin >> N >> K;
  ll ans = 0;
  ll digit = 0;
  ll tmp = N;
  vl P;
  while (tmp) {
    P.emplace_back(tmp % 10);
    digit++;
    tmp /= 10;
  }
  reverse((P).begin(), (P).end());
  vc<vvc<ll>> dp(digit + 1, vvc<ll>(K + 1, vc<ll>(2, 0)));
  dp[0][0][1] = 1;
  for (ll d = 0; d < (digit); d++) {
    for (ll k = 0; k < (K); k++) {
      if (P[d] == 0) {
        dp[d + 1][k][0] += dp[d][k][0];
        dp[d + 1][k + 1][0] += dp[d][k][0] * 9;
        dp[d + 1][k][1] = dp[d][k][1];
      } else {
        dp[d + 1][k][0] += dp[d][k][1] + dp[d][k][0];
        dp[d + 1][k + 1][0] += dp[d][k][1] * max(0ll, P[d] - 1);
        dp[d + 1][k + 1][0] += dp[d][k][0] * 9;
        dp[d + 1][k + 1][1] = dp[d][k][1];
      }
    }
    dp[d + 1][K][0] += dp[d][K][0];
    dp[d + 1][K][1] += dp[d][K][1];
  }
  cout << dp[digit][K][0] + dp[digit][K][1] << endl;
}
