#include <bits/stdc++.h>
using namespace std;
using dou = long double;
string yes = "yes";
string Yes = "Yes";
string YES = "YES";
string no = "no";
string No = "No";
string NO = "NO";
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;
}
const long long mod = 1000000007;
struct mint {
  long long x;
  mint(long long x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  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 { return mint(*this) += a; }
  mint operator-(const mint a) const { return mint(*this) -= a; }
  mint operator*(const mint a) const { return mint(*this) *= a; }
  mint pow(long long 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 { return mint(*this) /= a; }
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x; }
ostream& operator<<(ostream& os, const mint& a) { return os << a.x; }
long long ceil(long long a, long long b) { return ((a + b - 1) / b); }
const int INF = 2000000000;
const long long INF64 = 3223372036854775807ll;
const long long MOD = 1000000007ll;
const long long OD = 1000000000000007ll;
const dou pi = 3.141592653589793;
int main() {
  string s;
  std::cin >> s;
  int kk;
  std::cin >> kk;
  int n = s.size();
  std::vector<int> l(n);
  for (long long i = 0; i < (int)(n); i++) {
    l[i] = s[i] - '0';
  }
  vector<vector<vector<long long> > > dp(
      n, vector<vector<long long> >(10, vector<long long>(4, 0)));
  ;
  for (long long i = 1; i < (long long)(10); i++) {
    if (l[0] >= i) dp[0][i][1] += 1;
  }
  for (long long i = 1; i < (long long)(n); i++) {
    for (long long j = 1; j < (long long)(10); j++) {
      dp[i][j][1]++;
    }
    for (long long j = 0; j < (int)(10); j++) {
      if (j == 0) {
        for (long long k = 0; k < (int)(4); k++) {
          for (long long ii = 0; ii < (int)(10); ii++)
            dp[i][j][k] += dp[i - 1][ii][k];
        }
      } else {
        int ma = 10;
        if (j > l[i]) {
          ma = l[i - 1];
        }
        for (long long k = 0; k < (int)(3); k++) {
          for (long long ii = 0; ii < (int)(ma); ii++)
            dp[i][j][k + 1] += dp[i - 1][ii][k];
        }
      }
    }
  }
  long long ans = 0;
  for (long long i = 0; i < (int)(10); i++) ans += dp[n - 1][i][kk];
  std::cout << ans << std::endl;
}
