#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int choose(int n, int k, int nine) {
  if (n < k) return 0;
  int a = 1;
  for (int i = 0; i < nine; i++) {
    a *= 9;
  }
  if (k == 0) return a;
  if (k == 1)
    return n * a;
  else
    return (n - 1) * n / 2 * a;
}
int main() {
  int n, k;
  cin >> n >> k;
  int t = 0, tmp = n;
  while (tmp != 0) {
    t++;
    tmp /= 10;
  }
  int keta = 0;
  for (long long i = 0; i < t; ++i) {
    if (i == 0 || k > i) continue;
    keta += choose(i - 1, k - 1, k);
  }
  int ten = 1;
  for (long long i = 0; i < t - k; ++i) ten *= 10;
  n /= ten;
  vector<int> fr(k);
  tmp = n;
  for (int i = 0; i < k; i++) {
    fr[i] = tmp % 10;
    tmp /= 10;
  }
  int ans = keta;
  for (long long i = 0; i < k; ++i) {
    ans += (fr[i] - 1) * choose(t - k + i, i, i);
  }
  for (long long i = 0; i < k - 1; ++i) {
    ans += choose(t - k + i, 1 + i, i + 1);
  }
  ans++;
  cout << ans << endl;
  return 0;
}
