#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int mod = 1000000007;
struct mint {
  ll x;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod - a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res -= a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1) a *= *this;
    return a;
  }
  mint inv() const { return pow(mod - 2); }
  mint& operator/=(const mint a) { return (*this) *= a.inv(); }
  mint operator/(const mint a) const {
    mint res(*this);
    return res /= a;
  }
};
struct combination {
  vector<mint> fact, ifact;
  combination(int n) : fact(n + 1), ifact(n + 1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i - 1] * i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i - 1] = ifact[i] * i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n] * ifact[k] * ifact[n - k];
  }
};
mint ones(string n) {
  mint ans;
  ans = 0;
  if (n == "") return ans;
  int leng = (int)n.size();
  int maxint = n[0] - '0';
  for (int(i) = 0; (i) < (leng - 1); (i)++) {
    ans += 9;
  }
  ans += maxint;
  return ans;
}
mint twos(string n) {
  mint ans = 0;
  if (n == "") return ans;
  int leng = (int)n.size();
  int maxint = n[0] - '0';
  for (int(i) = 0; (i) < (leng - 2); (i)++) {
    mint add = 1;
    add *= 81;
    add *= (i + 1);
    ans += add;
  }
  mint add = 1;
  add *= 9;
  add *= (leng - 1) * (maxint - 1);
  ans += add;
  string s = n;
  s = s.erase(0, 1);
  ans += ones(s);
  return ans;
}
mint threes(string n) {
  mint ans = 0;
  if (n == "") return ans;
  int leng = (int)n.size();
  int maxint = n[0] - '0';
  for (int(i) = 0; (i) < (leng - 2); (i)++) {
    mint add = 1;
    add *= 9 * 9 * 9;
    add *= ((i + 1) * (i)) / 2;
    ans += add;
  }
  mint add = 1;
  add *= 9 * 9;
  add *= ((leng - 1) * (leng - 2) * (maxint - 1)) / 2;
  ans += add;
  string s = n;
  int i = 0;
  s = s.erase(0, 1);
  while (s[i] == '0' && s.size()) {
    s = s.erase(0, 1);
  }
  if (s.size() > 1) ans += twos(s);
  if (s.size() == 1) ans += ones(s);
  return ans;
}
int main() {
  string n;
  cin >> n;
  int k;
  cin >> k;
  mint ans = 0;
  if (k == 1) {
    ans = ones(n);
  }
  if (k == 2) {
    ans = twos(n);
  }
  if (k == 3) {
    ans = threes(n);
  }
  string s = "1";
  cout << ans.x;
}
