#include <bits/stdc++.h>
using namespace std;
using int64 = long long;
int64 max(int64 a, int64 b) {
  if (b > a)
    return b;
  else
    return a;
}
int64 min(int64 a, int64 b) {
  if (b < a)
    return b;
  else
    return a;
}
signed main() {
  string n;
  int64 K;
  cin >> n >> K;
  int64 l = n.size();
  vector<vector<vector<int64> > > dp(
      105, vector<vector<int64> >(2, vector<int64>(105, 0)));
  dp[0][0][0] = 1;
  for (int64 i = 0; i < l; i++) {
    int64 D = n[i] - '0';
    for (int64 j = 0; j < 2; j++) {
      for (int64 k = 0; k < 105; k++) {
        for (int64 d = 0; d <= (j ? 9 : D); d++) {
          if (d == 0)
            dp[i + 1][j || (d < D)][k + 1] += dp[i][j][k];
          else
            dp[i + 1][j || (d < D)][k] += dp[i][j][k];
        }
      }
    }
  }
  cout << dp[l][0][l - K] + dp[l][1][l - K] << endl;
  return 0;
}
