#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using vll = vector<ll>;
using vi = vector<int>;
using vb = vector<bool>;
using pll = pair<ll, ll>;
using pii = pair<int, int>;
using vpii = vector<pii>;
using vpll = vector<pll>;
const ll LINF = 1ll << 55;
const ll INF = 0x3f3f3f3f;
const ll MOD = 1e9 + 7;
const int MAXN = 2e5 + 10;
const ll dx[] = {1, 0, -1, 0};
const ll dy[] = {0, 1, 0, -1};
template <typename T>
ostream &operator<<(ostream &out, vector<T> &vec) {
  for (auto it = vec.begin(); it != vec.end(); ++it) {
    out << *it << " ";
  }
  return out;
}
template <typename T>
ostream &operator<<(ostream &out, pair<T, T> &P) {
  out << P.first << " " << P.second;
  return out;
}
template <typename T>
istream &operator>>(istream &in, vector<T> &vec) {
  for (auto it = vec.begin(); it != vec.end(); ++it) {
    in >> *it;
  }
  return in;
}
template <typename T>
istream &operator>>(istream &in, pair<T, T> &P) {
  in >> P.first >> P.second;
  return in;
}
class UnionFind {
  vector<ll> par;

 public:
  explicit UnionFind(ll n) : par(n, -1) {}
  ll root(ll a) {
    if (par[a] < 0) {
      return a;
    }
    return par[a] = root(par[a]);
  }
  ll size(ll a) { return -par[root(a)]; }
  void unite(ll a, ll b) {
    a = root(a);
    b = root(b);
    if (a != b) {
      if (size(a) < size(b)) {
        swap(a, b);
      }
      par[a] += par[b];
      par[b] = a;
    }
  }
};
ll factorial(ll n) {
  ll ret = 1;
  for (ll i = 1; i <= n; ++i) {
    ret = (ret * i) % MOD;
  }
  return ret;
}
ll inv_mod(ll n) {
  ll a = n % MOD, b = MOD - 2, ret = 1;
  while (b > 0) {
    if (b & 1) ret = (ret * a) % MOD;
    a = (a * a) % MOD;
    b >>= 1;
  }
  return ret;
}
ll nPr(ll n, ll r) {
  ll ret = 1;
  for (ll i = n; i >= n - r + 1; --i) {
    ret = ret * (i % MOD) % MOD;
  }
  return ret;
}
ll nCr(ll n, ll r) {
  if (r > n - r) {
    return nCr(n, n - r);
  }
  return nPr(n, r) * inv_mod(factorial(r)) % MOD;
}
ll nHr(ll n, ll r) { return nCr(n + r - 1, n - 1); }
inline ll ADD(ll a, ll b) { return (a + b) % MOD; }
inline ll MUL(ll a, ll b) { return (a % MOD) * (b % MOD) % MOD; }
inline ll SUB(ll a, ll b) { return (a + MOD - b) % MOD; }
inline ll POW(ll a, ll b) {
  ll ret = 1;
  while (b) {
    if (b & 1) ret = (ret * a) % MOD;
    a = (a * a) % MOD;
    b >>= 1;
  }
  return ret;
}
int main() {
  string S;
  int K;
  cin >> S >> K;
  int N = S.size();
  vector<vll> dp1(N, vll(K + 1));
  vector<vll> dp0(N, vll(K + 1));
  dp0[0][0] = 1;
  dp0[0][1] = (S[0] - '0') - 1;
  dp1[0][1] = 1;
  int cnt = 1;
  for (int i = 1; i < N; ++i) {
    for (int j = 1; j <= K; ++j) {
      if (S[i] == '0') {
        dp1[i][j] = dp1[i - 1][j];
      } else {
        ++cnt;
        if (cnt <= K) {
          dp1[i][cnt] = 1;
        }
      }
    }
  }
  for (int i = 1; i < N; ++i) {
    dp0[i][0] = 1;
    for (int j = 1; j <= K; ++j) {
      dp0[i][j] += dp0[i - 1][j - 1] * 9;
      dp0[i][j] += dp0[i - 1][j];
      if (S[i] != '0') {
        dp0[i][j] += dp1[i - 1][j - 1] * (S[i] - '0' - 1);
        dp0[i][j] += dp1[i - 1][j];
      }
    }
  }
  cout << (dp0[N - 1][K] + dp1[N - 1][K]) << endl;
  return 0;
}
