#include <bits/stdc++.h>
using namespace std;
template <class T>
inline int out(const T &t) {
  print(t);
  putchar('\n');
  return 0;
}
template <class T>
inline T gcd(T a, T b) {
  if (b == 0) return a;
  return (gcd(b, a % b));
}
template <class T>
inline T lcm(T a, T b) {
  return a / gcd(a, b) * b;
}
const long long INF = 1e18;
template <class T>
inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <int MOD>
struct ModInt {
  static const int Mod = MOD;
  unsigned x;
  ModInt() : x(0) {}
  ModInt(signed sig) {
    int sigt = sig % MOD;
    if (sigt < 0) sigt += MOD;
    x = sigt;
  }
  ModInt(signed long long sig) {
    int sigt = sig % MOD;
    if (sigt < 0) sigt += MOD;
    x = sigt;
  }
  int get() const { return (int)x; }
  ModInt &operator+=(ModInt that) {
    if ((x += that.x) >= MOD) x -= MOD;
    return *this;
  }
  ModInt &operator-=(ModInt that) {
    if ((x += MOD - that.x) >= MOD) x -= MOD;
    return *this;
  }
  ModInt &operator*=(ModInt that) {
    x = (unsigned long long)x * that.x % MOD;
    return *this;
  }
  ModInt &operator/=(ModInt that) { return *this *= that.inverse(); }
  ModInt operator+(ModInt that) const { return ModInt(*this) += that; }
  ModInt operator-(ModInt that) const { return ModInt(*this) -= that; }
  ModInt operator*(ModInt that) const { return ModInt(*this) *= that; }
  ModInt operator/(ModInt that) const { return ModInt(*this) /= that; }
  ModInt inverse() const {
    signed a = x, b = MOD, u = 1, v = 0;
    while (b) {
      signed t = a / b;
      a -= t * b;
      std::swap(a, b);
      u -= t * v;
      std::swap(u, v);
    }
    if (u < 0) u += Mod;
    ModInt res;
    res.x = (unsigned)u;
    return res;
  }
  bool operator==(ModInt that) const { return x == that.x; }
  bool operator!=(ModInt that) const { return x != that.x; }
  ModInt operator-() const {
    ModInt t;
    t.x = x == 0 ? 0 : Mod - x;
    return t;
  }
};
template <int MOD>
ModInt<MOD> operator^(ModInt<MOD> a, unsigned long long k) {
  ModInt<MOD> r = 1;
  while (k) {
    if (k & 1) r *= a;
    a *= a;
    k >>= 1;
  }
  return r;
}
ostream &operator<<(ostream &o, const ModInt<1000000007> v) {
  o << v.x;
  return o;
}
vector<ModInt<1000000007> > fact, rfact;
void constructFactorial(const long long n) {
  fact.resize(n);
  rfact.resize(n);
  fact[0] = rfact[0] = 1;
  for (int i = 0; i < n - 1; i++) {
    fact[i + 1] = fact[i] * (i + 1);
  }
  rfact[n - 1] = ModInt<1000000007>(1) / fact[n - 1];
  for (int i = n - 1; i >= 1; i--) rfact[i - 1] = rfact[i] * i;
}
ModInt<1000000007> nCr(const long long n, const long long r) {
  if (n < 0 || r < 0) return 0;
  if (n < r) return 0;
  return fact[n] * rfact[r] * rfact[n - r];
}
long long nCrNaive(const long long n, const long long k) {
  if (n < 0) return 0;
  if (k < 0) return 0;
  long long ret = 1;
  for (int i = 0; i < k; i++) {
    ret *= (long long)n - (long long)i;
    ret /= long long(i + 1);
  }
  return ret;
}
void solve(string N, long long K) {
  long long d = N.length();
  long long sum = 0;
  sum += (pow(9, K) * nCrNaive(d, K));
  if (K == 1) {
    sum -= ('9' - N[0]) * pow(9, K - 1);
  } else if (K == 2) {
    sum -= ('9' - N[0]) * (d - 1) * pow(9, K - 1);
    sum -= ('9' - N[1]);
  }
  cout << sum << endl;
}
int main() {
  string N;
  cin >> N;
  long long K;
  scanf("%lld", &K);
  solve(N, K);
  return 0;
}
