#include <bits/stdc++.h>
#pragma GCC optimize("O4")
using namespace std;
using ll = long long;
using pii = pair<ll, ll>;
ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
ll fpow(ll b, ll p) {
  b %= (ll)(1e9 + 7);
  ll ans = 1;
  while (p > 0) {
    if (p & 1) ans = (ans * b) % (ll)(1e9 + 7);
    p /= 2;
    b = (b * b) % (ll)(1e9 + 7);
  }
  return ans;
}
ll dp[110][4][2];
int32_t main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  string n;
  cin >> n;
  ll k;
  cin >> k;
  memset(dp, 0, sizeof(dp));
  dp[0][0][0] = 1;
  dp[0][0][1] = 0;
  dp[0][1][0] = n[0] - '0' - 1;
  dp[0][1][1] = 1;
  for (ll i = 1; i <= ((ll)n.size()) - 1; i++) {
    dp[i][0][0] = dp[i - 1][0][0];
    if (n[i] != '0') dp[i][0][0] += dp[i - 1][0][1];
    dp[i][0][1] = 0;
    if (n[i] == '0') dp[i][0][1] = dp[i - 1][0][1];
    for (ll j = 1; j <= k; j++) {
      dp[i][j][0] = dp[i - 1][j - 1][0] * 9 +
                    dp[i - 1][j - 1][1] * (n[i] - '0' - 1) + dp[i - 1][j][0];
      if (n[i] != '0') dp[i][j][0] += dp[i - 1][j][1];
      if (n[i] == '0')
        dp[i][j][1] = dp[i - 1][j][1];
      else
        dp[i][j][1] = dp[i - 1][j - 1][1];
    }
  }
  cout << dp[((ll)n.size()) - 1][k][0] + dp[((ll)n.size()) - 1][k][1] << "\n";
  return 0;
}
