#include <bits/stdc++.h>
using namespace std;
long long n, ans, d;
string S;
long long f[102];
int k;
void find_spec(int digit) {
  if (digit == d) {
    ans += S[digit - 1] - '0';
    if (k == 1) ans++;
    return;
  }
  if (S[digit - 1] - '0' > 1) {
    if (k == 2) {
      ans += (d - digit) * 9 * (S[digit - 1] - '0' - 1);
    } else if (k == 3) {
      ans += 81 * (d - digit) * (d - digit - 1) / 2 * (S[digit - 1] - '0' - 1);
    }
  }
  find_spec(digit + 1);
  return;
}
int main() {
  cin >> n;
  cin >> k;
  S = to_string(n);
  d = S.length();
  for (int i = k; i < d; i++) {
    if (i == k)
      f[i] = pow(9, k);
    else
      f[i] = (i - k) * pow(9, k);
    ans += f[i];
  }
  find_spec(1);
  cout.precision(6);
  cout << ans;
  return 0;
}
