#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const long long MOD = (long long)(1e9 + 7);
const long long INF = (long long)(1e13 + 7);
template <class T = long long>
long long in() {
  T x;
  cin >> x;
  return x;
}
long long bpm(long long x, long long y) {
  if (x == 0)
    return 0;
  else if (y == 0) {
    return 1;
  }
  long long ans = 1;
  x %= MOD;
  long long digit = (long long)((log((double)y) / log((double)2) / 1 + 1));
  for (long long i = 0; i < digit; i++) {
    if (((y >> i) & 1u) == 1) {
      ans *= x;
      ans %= MOD;
    }
    x = x * x;
    x %= MOD;
  }
  return ans;
}
long long inv_list[500000];
long long fac[500000];
long long finv[500000];
void nCk_init() {
  inv_list[0] = fac[0] = finv[0] = 1;
  for (long long i = 0; i < 500000 - 1; i++) {
    inv_list[i + 1] =
        MOD - ((inv_list[(MOD % (i + 2)) - 1] * (MOD / (i + 2))) % MOD);
    fac[i + 1] = (fac[i] * (i + 2)) % MOD;
    finv[i + 1] = (finv[i] * inv_list[i + 1]) % MOD;
  }
}
long long nCk(long long n, long long k) {
  if (n <= k || k <= 0) {
    return 1;
  }
  return (fac[n - 1] * ((finv[k - 1] * finv[n - k - 1]) % MOD)) % MOD;
}
class EAlmostEverywhereZero {
 public:
  static void solve(std::istream& cin, std::ostream& cout) {
    nCk_init();
    string S;
    long long K;
    cin >> S >> K;
    long long ans = 0;
    for (long long i = (long long)(1); i < (long long)(S.size()); i++) {
      if (i >= K) ans += nCk(i - 1, K - 1) * bpm(9, K);
    }
    vector<long long> product(S.size());
    vector<long long> cum_sum(S.size(), 0);
    for (long long i = 0; i < (long long)(S.size()); i++) {
      product[i] = stoi(string(1, S[i]));
    }
    for (long long i = 0; i < (long long)(S.size() - 1); i++) {
      cum_sum[i + 1] = product[i + 1];
      cum_sum[i + 1] += cum_sum[i];
    }
    if (K == 1) {
      ans += product[0];
    } else if (K == 2) {
      long long i = 0;
      for (long long j = (long long)(i + 1); j < (long long)(S.size()); j++) {
        if (cum_sum[i] != 0 || j == i + 1) {
          ans += 9 * (product[i] - 1) + product[j];
        } else {
          ans += 9 * product[i];
        }
      }
    } else {
      long long i = 0;
      for (long long j = (long long)(i + 1); j < (long long)(S.size() - 1);
           j++) {
        for (long long k = (long long)(j + 1); k < (long long)(S.size()); k++) {
          if (cum_sum[j] != 0 && j != i + 1 && k != j + 1) {
            ans += 81 * product[i];
          } else if (cum_sum[j] == 0 && cum_sum[k] != 0 && j != i + 1) {
            ans += (product[i] - 1) * 81 + product[j] * 9;
          } else {
            ans += (product[i] - 1) * 81 + (product[j] - 1) * 9 + product[k];
          }
        }
      }
    }
    cout << ans << endl;
  }
};
signed main() {
  EAlmostEverywhereZero solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}
