#include <bits/stdc++.h>
using namespace std;
const long long INF = 1LL << 60;
const long long MOD = 1000000007;
template <class T>
inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
long long cmb(int n, int k) {
  long long coef = 1;
  vector<long long> sieve(n + 1, 0);
  if (n < k) {
    coef = 0;
    return coef;
  }
  if (n == k || k == 0) {
    coef = 1;
    return coef;
  }
  k = min(k, n - k);
  for (long long p = 2; p <= n; p++) {
    if (sieve.at(p) == 0) {
      for (long long i = p * p; i <= n; i += p) {
        sieve.at(i) = 1;
      }
      for (long long prime = p; prime <= n; prime *= p) {
        long long cnt = n / prime - k / prime - (n - k) / prime;
        for (long long j = 0; j < cnt; j++) {
          coef *= p;
          coef %= MOD;
        }
      }
    }
  }
  return coef;
}
int main() {
  string s;
  cin >> s;
  int k;
  cin >> k;
  int size = s.size();
  if (k == 1) {
    long long ans = 9 * (size - 1) + (s[0] - '0');
    cout << ans << endl;
    return 0;
  }
  if (k == 2) {
    if (size == 1) {
      cout << 0 << endl;
      return 0;
    }
    long long ans =
        (s[1] - '0') + 9 * (size - 2) + (s[0] - '0' - 1) * 9 * (size - 1);
    if (size > 2) {
      ans += cmb(size - 1, 2) * 9 * 9;
    }
    cout << ans << endl;
    return 0;
  }
  if (k == 3) {
    if (size < 3) {
      cout << 0 << endl;
      return 0;
    }
    long long ans = 9 * 9 * 9 * cmb(size - 1, 3) + (s[2] - '0') +
                    9 * (size - 3) + (s[1] - '0' - 1) * 9 * (size - 2) +
                    9 * 9 * cmb(size - 2, 2) +
                    (s[0] - '0' - 1) * (cmb(size - 1, 2) * 9 * 9);
    cout << ans << endl;
    return 0;
  }
}
