#include <bits/stdc++.h>
template <class T>
inline T chmax(T& a, const T b) {
  return a = (a < b) ? b : a;
}
template <class T>
inline T chmin(T& a, const T b) {
  return a = (a > b) ? b : a;
}
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const ll MOD = 1000000007;
const ll INF = 1e18;
const double PI = acos(-1);
using namespace std;
signed main() {
  string s;
  cin >> s;
  ll K;
  cin >> K;
  ll N = s.size();
  ll dp[1100][5][5];
  dp[0][0][0] = 1;
  for (ll i = 0; i < ll(N); ++i)
    for (ll j = 0; j < ll(K + 1); ++j)
      for (ll k = 0; k < ll(2); ++k) {
        ll lim = k ? 9 : (s[i] - '0');
        if (lim == 0)
          dp[i + 1][j][k] += dp[i][j][k];
        else {
          dp[i + 1][j][1] += dp[i][j][k];
          dp[i + 1][j + 1][1] += (lim - 1) * dp[i][j][k];
          dp[i + 1][j + 1][0] += dp[i][j][k];
        }
      }
  ll ans = 0;
  for (ll k = 0; k < ll(2); ++k) ans += dp[N][K][k];
  cout << ans << endl;
  return 0;
}
