#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
void Main() {
  string S;
  ll K;
  cin >> S >> K;
  ll N = S.size();
  vector<vector<vector<ll>>> dp(N + 1,
                                vector<vector<ll>>(2, vector<ll>(N + 1, 0)));
  dp[0][0][0] = 1;
  for (ll i = 0; i < (ll)(N); i++) {
    for (ll k = 0; k < (ll)(i + 1); k++) {
      for (ll j = 0; j < (ll)(2); j++) {
        int d = S[i] - '0';
        if (j == 1) {
          d = 9;
        }
        for (ll m = 0; m < (ll)(d + 1); m++) {
          if (m == 0) {
            if (j == 1) {
              dp[i + 1][1][k + 1] += dp[i][1][k];
            } else {
              if (m < d) {
                dp[i + 1][1][k + 1] += dp[i][0][k];
              } else {
                dp[i + 1][0][k + 1] += dp[i][0][k];
              }
            }
          } else {
            if (j == 1) {
              dp[i + 1][1][k] += dp[i][1][k];
            } else {
              if (m < d) {
                dp[i + 1][1][k] += dp[i][0][k];
              } else {
                dp[i + 1][0][k] += dp[i][0][k];
              }
            }
          }
        }
      }
    }
  }
  ll ans = dp[N][1][N - K] + dp[N][0][N - K];
  cout << ans << '\n';
}
int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  Main();
  return 0;
}
