#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
long long fac[100005], finv[100005], inv[100005];
void COMinit() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < 100005; i++) {
    fac[i] = fac[i - 1] * i % 1000000007;
    inv[i] = 1000000007 - inv[1000000007 % i] * (1000000007 / i) % 1000000007;
    finv[i] = finv[i - 1] * inv[i] % 1000000007;
  }
}
long long COM(int n, int k) {
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n - k] % 1000000007) % 1000000007;
}
int find1(string s, int x) {
  int a = s[x] - '0';
  return 9 * (s.length() - 1 - x) + a;
}
int find2(string s, int x) {
  int a = s[x] - '0';
  int i = x + 1;
  while (s[i] - '0' == 0 && i < s.length()) i++;
  return COM(s.length() - 1 - x, 2) * pow(9, 2) + find1(s, i) +
         (a - 1) * (s.length() - 1 - x) * 9;
}
int find3(string s, int x) {
  int a = s[x] - '0';
  int i = x + 1;
  while (s[i] - '0' == 0 && i < s.length()) i++;
  return find2(s, i) + COM(s.length() - 1 - x, 3) * pow(9, 3) +
         (a - 1) * COM(s.length() - 1 - x, 2) * pow(9, 2);
}
int main() {
  COMinit();
  string s;
  int k;
  cin >> s >> k;
  if (s.length() < k)
    cout << 0 << endl;
  else {
    if (k == 3)
      cout << find3(s, 0);
    else if (k == 2)
      cout << find2(s, 0);
    else
      cout << find1(s, 0);
    cout << endl;
  }
}
