#include <bits/stdc++.h>
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;
}
using namespace std;
int main() {
  string S;
  cin >> S;
  int K;
  cin >> K;
  long long ans = 0;
  long long dp[101][2][5];
  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) {
    int D = S[i] - '0';
    for (int j = 0; j < 2; ++j) {
      for (int k = 0; k < 5; ++k) {
        for (int d = 0; d <= (j ? 9 : D); ++d) {
          if (d > 0) dp[i + 1][j || (d < D)][k + 1] += dp[i][j][k];
          if (d == 0) dp[i + 1][j || (d < D)][k] += dp[i][j][k];
        }
      }
    }
  }
  cout << dp[L][0][K] + dp[L][1][K] << endl;
  return 0;
}
