#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int N = 2e5 + 10;
ll c(int n, int k) {
  ll ans = 1;
  for (int i = 0; i < k; i++) {
    ans *= (n - i);
  }
  for (int i = 1; i <= k; i++) {
    ans /= i;
  }
  return ans;
}
int main() {
  string s;
  cin >> s;
  int n = s.length();
  int k;
  cin >> k;
  ll ans = 0;
  for (int i = 0; i <= k; i++) {
    ans += c(n - i - 1, k - i) * pow(9, k - i);
    if (k - i == 0) break;
    ans += (s[i] - '0' - 1) * c(n - i - 1, k - i - 1) * pow(9, k - i - 1);
  }
  cout << ans;
}
