#include <bits/stdc++.h>
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
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;
struct INIT {
  INIT() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
  }
} INIT;
signed main() {
  string s;
  cin >> s;
  ll K;
  cin >> K;
  ll N = s.size();
  ll dp[N + 1][K + 2][2];
  memset(dp, 0, sizeof(dp));
  dp[0][0][0] = 1;
  for (ll i = 0; i < ll(N); ++i)
    for (ll j = 0; j < ll(K + 1); ++j) {
      ll d = s[i] - '0';
      dp[i + 1][j][1] += dp[i][j][0];
      dp[i + 1][j][1] += dp[i][j][1];
      dp[i + 1][j + 1][1] += dp[i][j][1] * 9;
      if (d != 0) {
        dp[i + 1][j + 1][1] += dp[i][j][0] * (d - 1);
        dp[i + 1][j + 1][0] += dp[i][j][0];
      }
    }
  cout << dp[N][K][0] + dp[N][K][1] << "\n";
  return 0;
}
