#include <bits/stdc++.h>
using namespace std;
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
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;
}
using ll = long long;
using P = pair<ll, ll>;
constexpr long double PI = 3.14159265358979323846264338327950288L;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
class EAlmostEverywhereZero {
 public:
  void solve(istream& cin, ostream& cout) {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    string s;
    cin >> s;
    int n = s.size();
    int k;
    cin >> k;
    vector<int> v;
    for (auto e : s) {
      v.push_back(e - '0');
    }
    vector<vector<ll>> a(n + 1, vector<ll>(4));
    vector<vector<ll>> b(n + 1, vector<ll>(4));
    a[0][0] = 1;
    for (int i = 0; i < (int)(n); i++) {
      int e = v[i];
      if (e != 0) {
        for (int j = 0; j <= k; j++) {
          b[i + 1][j] += a[i][j];
          if (j < k) b[i + 1][j + 1] += (e - 1) * a[i][j];
          if (j < k) a[i + 1][j + 1] += a[i][j];
        }
        for (int j = 0; j <= k; j++) {
          b[i + 1][j] += b[i][j];
          if (j < k) b[i + 1][j + 1] += 9 * b[i][j];
        }
      } else {
        for (int j = 0; j <= k; j++) {
          b[i + 1][j] += a[i][j];
          b[i + 1][j] += b[i][j];
          if (j < k) b[i + 1][j + 1] += 9 * b[i][j];
        }
      }
    }
    cout << a[n][k] + b[n][k] << endl;
  }
};
signed main() {
  EAlmostEverywhereZero solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}
