#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll dp[109][4][2];
int main() {
  string S;
  int K;
  cin >> S >> K;
  int N = S.size();
  dp[0][0][0] = 1;
  for (int i = 0; i < (N); ++i) {
    ll D = S[i] - '0';
    for (int j = 0; j < (K + 1); ++j) {
      for (int k = 0; k < (2); ++k) {
        dp[i + 1][j][k || (D > 0)] += dp[i][j][k];
        if (k == 0) {
          if (D == 0) continue;
          dp[i + 1][j + 1][k] += dp[i][j][k];
          dp[i + 1][j + 1][1] += (D - 1) * dp[i][j][k];
        } else {
          dp[i + 1][j + 1][k] += 9LL * dp[i][j][k];
        }
      }
    }
    cerr << "i:" << i << " dp:" << dp[i + 1][K][1] << endl;
  }
  cerr << dp[N][K][0] << " " << dp[N][K][1] << endl;
  cout << dp[N][K][0] + dp[N][K][1] << endl;
  return 0;
}
