#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  int k;
  cin >> s >> k;
  if (s.size() < k) {
    cout << 0 << endl;
    return 0;
  }
  if (s.size() == 1) {
    if (k == 1) cout << 9 << endl;
    return 0;
  }
  long long cnt = 0LL;
  for (int i = k; i < s.size(); i++) {
    if (k == 1)
      cnt += 1LL * 9;
    else if (k == 2)
      cnt += 1LL * 9 * (i - 1) * 9;
    else
      cnt += 1LL * 9 * (i - 1) * (i - 2) / 2 * 81;
  }
  if (k == 1) {
    cnt += (int)(s[0] - '0');
  } else if (k == 2) {
    cnt += 1LL * (int)(s[0] - '0' - 1) * (s.size() - 1) * 9;
    for (int i = 1; i < s.size(); i++) {
      cnt += (int)(s[i] - '0');
    }
  } else {
    cnt +=
        1LL * (int)(s[0] - '0' - 1) * (s.size() - 1) * (s.size() - 2) / 2 * 81;
    for (int i = 1; i < s.size() - 1; i++) {
      cnt += 1LL * (int)(s[i] - '0' - 1) * (s.size() - i - 1) * 9;
      for (int j = i + 1; j < s.size(); j++) {
        cnt += (int)(s[j] - '0');
      }
    }
  }
  cout << cnt << endl;
  return 0;
}
