#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll inf = 1000000001, INF = (ll)1e18 + 1;
int power(int a, int b) {
  int result = 1;
  while (b) {
    if (b % 2) result = (result * a) % 1000000007;
    a = (a * a) % 1000000007;
    b /= 2;
  }
  return result;
}
int C(int n, int k) {
  double res = 1;
  for (int i = 1; i <= k; ++i) res = res * (n - k + i) / i;
  return (int)(res + 0.01);
}
void solve() {
  string s;
  cin >> s;
  int n = s.length(), k;
  cin >> k;
  if (n < k) {
    cout << 0 << endl;
    return;
  }
  int ans = C(n, k) * power(9, k);
  for (int i = 0; i < k; i++) {
    int d = s[i] - '0';
    ans -= (9 - d) * C(n - (i + 1), k - (i + 1)) * power(9, k - (i + 1));
  }
  cout << ans << endl;
}
int main() {
  ios_base::sync_with_stdio(false);
  solve();
  return 0;
}
