#include <bits/stdc++.h>
using namespace std;
long long INF = 1e18;
long long mod = 1e9 + 7;
template <typename T>
inline string toString(const T &a) {
  ostringstream oss;
  oss << a;
  return oss.str();
};
long long dp[101][2][101];
int K;
long long solve(const string &s) {
  const int L = s.size();
  fill((long long *)dp, (long long *)dp + sizeof(dp) / sizeof(long long), 0);
  dp[0][0][0] = 1;
  for (int i = 0; i < L; i++) {
    const int D = s[i] - '0';
    for (int j = 0; j < 2; j++) {
      for (int k = 0; k <= K; k++) {
        for (int d = 0; d <= (j ? 9 : D); d++) {
          if (d == 0)
            dp[i + 1][j || (d <= D)][k] += dp[i][j][k];
          else {
            dp[i + 1][j || (d < D)][k + 1] += dp[i][j][k];
          }
        }
      }
    }
  }
  return dp[L][1][K] + dp[L][0][K];
}
int main() {
  string s;
  cin >> s;
  cin >> K;
  cout << solve(s) << endl;
  return 0;
}
