#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e18;
const ll MOD = 1e9 + 7;
const int MAX = 510000;
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAX; i++) {
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}
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] % MOD) % MOD;
}
int main() {
  string s;
  cin >> s;
  ll k;
  cin >> k;
  vector<string> t;
  string head;
  head = s.substr(0, k);
  if (k == 1) {
    for (int i = int(1); i < int(10); i++) {
      string r = to_string(i);
      t.push_back(r);
    }
  } else if (k == 2) {
    for (int i = int(11); i < int(100); i++) {
      if (i % 10 != 0) {
        string r = to_string(i);
        t.push_back(r);
      }
    }
  } else {
    for (int i = int(111); i < int(1000); i++) {
      if ((201 <= i && i <= 210) || (301 <= i && i <= 310) ||
          (401 <= i && i <= 410) || (501 <= i && i <= 510) ||
          (601 <= i && i <= 610) || (701 <= i && i <= 710) ||
          (801 <= i && i <= 810) || (901 <= i && i <= 910)) {
        continue;
      }
      if (i % 10 != 0) {
        string r = to_string(i);
        t.push_back(r);
      }
    }
  }
  COMinit();
  ll ans = 0;
  for (int i = int(0); i < int((int)(t).size()); i++) {
    ll size;
    if (t[i] <= head) {
      size = (int)(s).size();
      ans += COM(size, k);
    } else {
      size = (int)(s).size() - 1;
      ans += COM(size, k);
    }
  }
  cout << ans << endl;
}
