#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  int k;
  cin >> k;
  int c[101][4] = {0};
  int maxn = s.length();
  for (int i = 1; i <= maxn; i++) {
    c[i][1] = 9 * (i - 1) + s[maxn - i];
    c[i][2] = 9 * 9 * (i - 1) * (i - 2) / 2 + s[maxn - i] * c[i - 1][1];
    c[i][3] =
        9 * 9 * 9 * (i - 1) * (i - 2) * (i - 3) / 6 + s[maxn - i] * c[i - 1][2];
  }
  cout << c[maxn][k] << endl;
  return 0;
}
