#include <bits/stdc++.h>
using namespace std;
long long momonck[5] = {0};
long long nck(long long n, long long k) {
  if (k == 0) return 1;
  if (momonck[k] != 0) {
    return momonck[k];
  }
  long long rnum = 1, waru = 1;
  for (long long i = 0; i < k; i++) {
    rnum *= (n - i);
    waru *= (1 + i);
  }
  momonck[k] = rnum / waru;
  return momonck[k];
}
int main() {
  string n, k;
  long long ans, count = 0, memory = 1;
  cin >> n >> k;
  ans = pow(9, stoi(k)) *
        (nck(n.length(), stoi(k)) - nck(n.length() - 1, stoi(k) - 1));
  cout << ans << endl;
  for (long long i = 0; i < n.length(); i++) {
    if (count == stoi(k)) break;
    if ((int)n[i] - '0' != 0) {
      cout << "aa" << (int)n[i] - '0' << endl;
      count++;
      memory = (int)n[i] - '0';
      ans += pow(9, stoi(k) - i - 1) *
             nck(n.length() - i - 1, stoi(k) - i - 1) * memory;
      cout << "bb"
           << pow(9, stoi(k) - i - 1) *
                  nck(n.length() - i - 1, stoi(k) - i - 1) * memory
           << endl;
    }
  }
  ans--;
  cout << ans << endl;
}
