#include <bits/stdc++.h>
using namespace std;
string n;
int k;
int solve(int num, int keta, int m) {
  if (keta + num > n.length()) return 0;
  int res;
  if (num == 1) {
    if (m) {
      res = n[keta] - '0';
    } else {
      res = 9;
    }
    res += solve(num, keta + 1, 0);
    return res;
  } else {
    if (m) {
      res = solve(num - 1, keta + 1, 1);
      res += (n[keta] - '0' - 1) * solve(num - 1, keta + 1, 0);
    } else {
      res = 9 * solve(num - 1, keta + 1, 0);
    }
    res += solve(num, keta + 1, 0);
    return res;
  }
}
int main() {
  cin >> n >> k;
  cout << solve(k, 0, 1) << "\n";
  return 0;
}
