#include <bits/stdc++.h>
using namespace std;
const int INF = 1 << 30;
const long long INFL = 1LL << 62;
const int MOD = 1000000007;
const int MAX = 100000;
const int N = 100010;
long long com(int r, int c) {
  if (c == 0) return 1ll;
  if (r < c) return 0ll;
  long long ret = 1ll;
  for (int i = 1; i <= c; i++) {
    ret *= r - i + 1;
  }
  for (int i = 1; i <= c; i++) {
    ret /= i;
  }
  return ret;
}
int main() {
  string n;
  cin >> n;
  int k;
  cin >> k;
  int remain_n = n.size();
  int remain_k = k;
  long long ans = 0;
  for (int i = 0; i < (n.size()); i++) {
    if (n[i] != '0') {
      ans +=
          (n[i] - '1') * com(remain_n - 1, remain_k - 1) * pow(9, remain_k - 1);
      ans += com(remain_n - 1, remain_k) * pow(9, remain_k);
      remain_k--;
    }
    if (remain_k == 0) break;
    remain_n--;
  }
  cout << ans + 1 << endl;
}
