#include <bits/stdc++.h>
using namespace std;
int combi(int n, int k) {
  if (n < k) return 0;
  int tmp = 1;
  for (long long i = 0; i < (k); i++) {
    tmp *= n - i;
  }
  for (long long i = 0; i < (k); i++) {
    tmp /= i + 1;
  }
  return tmp;
}
int mypow[4] = {1, 9, 81, 729};
int main() {
  string n;
  int k;
  cin >> n;
  cin >> k;
  if (n.size() == 1) {
    if (k == 1) {
      cout << n << endl;
    } else {
      cout << 0 << endl;
    }
  } else {
    int ans = 0;
    if (n.size() >= k) {
      ans = combi(n.size() - 1, k) * mypow[k];
      if (k == 1) {
        int tmp1 = n[0] - '0';
        cout << ans + tmp1 << endl;
      } else if (k == 2) {
        int tmp1 = n[0] - '0';
        int tmp2 = 0;
        tmp2 = n[1] - '0';
        for (int i = 2; i < n.size(); i++) {
          tmp2 += 9;
        }
        cerr << ans << endl;
        cerr << tmp1 << endl;
        cerr << tmp2 << endl;
        cout << ans + (1 * tmp2 + (tmp1 - 1) * 9 * (n.size() - 1)) << endl;
      } else {
        int tmp1 = n[0] - '0';
        int tmp2 = 0;
        for (int i = 1; i < n.size() - 1; i++) {
          for (int j = i + 1; j < n.size(); j++) {
            tmp2 += (n[i] - '0') * (n[j] - '0');
          }
        }
        cerr << ans << endl;
        cerr << tmp1 << endl;
        cerr << tmp2 << endl;
        cout << ans + (1 * tmp2 + (tmp1 - 1) * combi(n.size() - 1, 2) * 81)
             << endl;
      }
    }
  }
  return 0;
}
