#include <bits/stdc++.h>
using namespace std;
string N;
int M;
int K;
int64_t recursive(int i, int k, bool f) {
  if (k == K) {
    return 1;
  } else if (i == M) {
    return 0;
  }
  int64_t ret = 0;
  ret += recursive(i + 1, k, false);
  int last = 9;
  if (i == 0)
    last = (N[i] - '0');
  else if (f) {
    last = (N[i] - '0');
    if (last == 0) last = 9;
  }
  for (int j = 1; j <= last; ++j) {
    ret += recursive(i + 1, k + 1, f && (j == last));
  }
  return ret;
}
int main(void) {
  ios::sync_with_stdio(false);
  cin >> N >> K;
  M = N.size();
  int64_t answer = recursive(0, 0, true);
  cout << answer << endl;
  return 0;
}
