#include <bits/stdc++.h>
using namespace std;
inline void IN(void) { return; }
template <typename First, typename... Rest>
void IN(First& first, Rest&... rest) {
  cin >> first;
  IN(rest...);
  return;
}
inline int p(void) {
  cout << endl;
  return 0;
}
template <class Head>
int p(Head&& head) {
  cout << head;
  p();
  return 0;
}
template <class Head, class... Tail>
int p(Head&& head, Tail&&... tail) {
  cout << head << " ";
  p(forward<Tail>(tail)...);
  return 0;
}
struct ProconInit {
  static constexpr bool AUTOFLUSH = false;
  ProconInit() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    if (AUTOFLUSH) cout << unitbuf;
  }
} PROCON_INIT;
template <class T>
bool chmax(T& a, const T& b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
bool chmin(T& a, const T& b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
bool cmp(pair<long long, long long> a, pair<long long, long long> b) {
  return a.first + a.second > b.first + b.second;
}
long long dp[2][110][50];
int main() {
  string s;
  long long k;
  cin >> s >> k;
  long long n = s.size();
  dp[0][0][0] = 1;
  for (long long id = 0; id < 2; id++) {
    for (long long i = 0; i < n; i++) {
      for (long long j = 0; j < 4; j++) {
        long long lim = s[i] - '0';
        if (id) {
          lim = 9;
        }
        for (long long x = 0; x < lim; x++) {
          dp[id || x < lim][i + 1][j + (x != 0)] += dp[id][i][j];
        }
      }
    }
  }
  long long ans = 0;
  for (long long id = 0; id < 2; id++) {
    ans += dp[id][n][k];
  }
  p(ans);
  return 0;
}
