#include <bits/stdc++.h>
using namespace std;
int to_int(char s) { return s - '0'; }
int main() {
  string S;
  cin >> S;
  int N = S.size();
  int K;
  cin >> K;
  vector<vector<vector<long long>>> dp(
      N + 1, vector<vector<long long>>(K + 1, vector<long long>(2)));
  dp[0][K][1] = 1;
  for (int i = 0; i < N; ++i) {
    for (int j = 0; j <= K; ++j) {
      for (int f = 0; f < 2; ++f) {
        if (f) {
          if (to_int(S[i]) == 0 && i != 0)
            dp[i + 1][j][f] += dp[i][j][1];
          else {
            if (j + 1 <= K) dp[i + 1][j][f] += dp[i][j + 1][1];
          }
        } else {
          if (to_int(S[i]) == 0) {
            dp[i + 1][j][f] += dp[i][j][0] + dp[i][j][1];
            if (j + 1 <= K) dp[i + 1][j][f] += dp[i][j + 1][0] * 9;
          } else {
            dp[i + 1][j][f] += dp[i][j][0];
            if (j + 1 <= K)
              dp[i + 1][j][f] +=
                  dp[i][j + 1][0] * 9 + dp[i][j + 1][1] * (to_int(S[i]) - 1);
          }
        }
      }
    }
  }
  cout << dp[N][0][0] + dp[N][0][1] << endl;
}
