#include <bits/stdc++.h>
using ll = long long;
using ull = unsigned long long;
using pii = std::pair<int, int>;
using pll = std::pair<long long, long long>;
using namespace std;
const long long MOD = 1000000007;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  string n;
  int k;
  cin >> n >> k;
  if (n.length() < k) {
    cout << 0 << "\n";
    return 0;
  } else if (n.length() == k && n[0] == '1' && k != 1) {
    if (n[1] == '0') {
      cout << 0 << "\n";
      return 0;
    }
  }
  ll l = n.length() - 1;
  ll ans = 0;
  if (l >= k) {
    ans = 1;
    for (int i = 0; i < k; ++i) ans *= l - i;
    for (int i = 0; i < k - 1; ++i) ans /= k - i;
    ll p = 1;
    for (int i = 0; i < k; ++i) p *= 9;
    ans *= p;
  }
  ll t = (ll)n[0] - '0';
  if (k != 1) {
    --k;
    ll q = 1;
    for (int i = 0; i < k; ++i) q *= l - i;
    for (int i = 0; i < k - 1; ++i) q /= k - i;
    ll p = 1;
    for (int i = 0; i < k; ++i) p *= 9;
    q *= p;
    ans += q * t;
    ll s = (ll)n[1] - '0';
    if (k == 1) {
      ans -= 9 - s;
    } else {
      ans -= (9 - s) * (l - 1) * 9;
      ll r = (ll)n[2] - '0';
      ans -= 9 - r;
    }
  } else {
    ans += t;
  }
  cout << ans << "\n";
  return 0;
}
