#include <bits/stdc++.h>
using namespace std;
const int mod = 1000000007;
const int INF = 1001001001;
long long comb(int n, int r) {
  if (n == 0) return 0;
  vector<vector<long long>> v(n + 1, vector<long long>(n + 1, 0));
  for (int i = 0; i < v.size(); i++) {
    v[i][0] = 1;
    v[i][i] = 1;
  }
  for (int j = 1; j < v.size(); j++) {
    for (int k = 1; k < j; k++) {
      v[j][k] = (v[j - 1][k - 1] + v[j - 1][k]);
    }
  }
  return v[n][r];
}
int main() {
  string s;
  int k;
  cin >> s;
  cin >> k;
  int n = (int)(s.size());
  long long ans = 0;
  for (int i = 0; i <= n - 2; ++i) {
    if (s[i] == '0') continue;
    if (k == 0) break;
    int zan = n - (i + 1);
    ans += comb(zan, k) * pow(9, k) +
           comb(zan, k - 1) * (int)(s[i] - '1') * pow(9, k - 1);
    k--;
  }
  if (k == 0) {
    ans++;
  } else {
    if (k == 1) {
      if (s[n - 1] == '0')
        ans += 0;
      else
        ans += (int)(s[n - 1] - '0');
    } else {
    }
  }
  cout << ans << endl;
  return 0;
}
