#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000000007;
using ll = long long;
using P = pair<int, int>;
int choose(int n, int k) {
  int num = 1, denom = 1;
  for (int i = 0; i < k; ++i) {
    num *= n - i;
    denom *= i + 1;
  }
  return num / denom;
}
int main() {
  string s;
  int k;
  cin >> s >> k;
  int n = s.size();
  if (n < k) {
    cout << 0 << endl;
    return 0;
  }
  int ans = 0;
  int n2 = n;
  for (int i = 0; i < n; ++i) {
    int ni = s[i] - '0';
    int tmp = choose(n2 - 1, k);
    for (int i = 0; i < k; ++i) tmp *= 9;
    int tmp2 = choose(n2 - 1, k - 1);
    tmp2 *= ni - 1;
    for (int i = 0; i < k - 1; ++i) tmp2 *= 9;
    ans += tmp + tmp2;
    --k;
    --n2;
    if (k == 0) break;
  }
  if (ans >= 0) ++ans;
  cout << max(0, ans) << endl;
  return 0;
}
