#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int N, H = 1;
  int K, ans, count;
  cin >> N >> K;
  for (int i = 1; i < K; i++) H *= 10;
  count = K - 1;
  if (K == 1) {
    while (N > (H * 10)) {
      ans += 9;
      H *= 10;
    }
    ans += N / H;
  }
  if (K == 2) {
    while (N > (H * 10)) {
      ans += 9 * count * 9;
      H *= 10;
      count++;
    }
    ans += (N / H) * count * 9;
    N %= H;
    H /= 10;
    ans -= (9 - N / H);
  }
  if (K == 3) {
    while (N > (H * 10)) {
      ans += 9 * count * 9 * (count - 1) * 9;
      H *= 10;
      count++;
    }
    ans += (N / H) * count * 9;
    N %= H;
    H /= 10;
    ans -= (9 - (N / H)) * 9;
    N %= H;
    H /= 10;
    ans -= (9 - (N / H));
  }
  cout << ans << endl;
  return 0;
}
