#include <bits/stdc++.h>
using namespace std;
using P = pair<long long, long long>;
using WeightedGraph = vector<vector<P>>;
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;
}
template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
  for (T &x : vec) is >> x;
  return is;
}
template <typename T, typename U>
ostream &operator<<(ostream &os, pair<T, U> &pair_var) {
  os << "(" << pair_var.first << ", " << pair_var.second << ")";
  return os;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  os << "{";
  for (long long i = 0; i < vec.size(); i++) {
    os << vec[i] << (i + 1 == vec.size() ? "" : ", ");
  }
  os << "}";
  return os;
}
template <typename T, typename U>
ostream &operator<<(ostream &os, map<T, U> &map_var) {
  os << "{";
  for (auto itr = map_var.begin(); itr != map_var.end(); itr++) {
    os << *itr;
    itr++;
    if (itr != map_var.end()) os << ", ";
    itr--;
  }
  os << "}";
  return os;
}
template <typename T>
ostream &operator<<(ostream &os, set<T> &set_var) {
  os << "{";
  for (auto itr = set_var.begin(); itr != set_var.end(); itr++) {
    os << *itr;
    itr++;
    if (itr != set_var.end()) os << ", ";
    itr--;
  }
  os << "}";
  return os;
}
void dump_func() { cerr << endl; }
template <class Head, class... Tail>
void dump_func(Head &&head, Tail &&...tail) {
  cerr << head;
  if (sizeof...(Tail) > 0) {
    cerr << ", ";
  }
  dump_func(std::move(tail)...);
}
signed main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s;
  cin >> s;
  long long n = s.size();
  long long k;
  cin >> k;
  vector<vector<vector<long long>>> dp(
      2, vector<vector<long long>>(k + 100, vector<long long>(n + 10)));
  dp[1][0][0] = 1;
  for (long long(j) = 0; (j) < (n); (j)++) {
    for (long long(i) = 0; (i) < (k + 10); (i)++) {
      long long now = s[i] - '0';
      for (long long(nd) = 0; (nd) < (10); (nd)++) {
        long long use = 0;
        if (nd != 0) use = 1;
        if (nd > now) {
          dp[0][i + use][j + 1] += dp[0][i][j];
        } else if (nd == now) {
          dp[0][i + use][j + 1] += dp[0][i][j];
          dp[1][i + use][j + 1] += dp[1][i][j];
        } else {
          dp[0][i + use][j + 1] += dp[1][i][j] + dp[0][i][j];
        }
      }
    }
  }
  cout << dp[0][k][n] + dp[1][k][n] << endl;
}
