#include <bits/stdc++.h>
using namespace std;
using ll = long long;
signed main() {
  string S;
  int K;
  cin >> S >> K;
  int N = (int)S.size();
  vector<vector<ll>> dp_equal(N + 1, vector<ll>(4, 0));
  vector<vector<ll>> dp_less(N + 1, vector<ll>(4, 0));
  dp_equal[0][0] = 1;
  for (int i = 1; i <= N; i++) {
    int now = (int)(S[i - 1] - '0');
    for (int j = 0; j <= K; j++) {
      if (now != 0 and j >= 1)
        dp_equal[i][j] = dp_equal[i - 1][j - 1];
      else
        dp_equal[i][j] = dp_equal[i - 1][j];
      if (j >= 1) {
        dp_less[i][j] += dp_less[i - 1][j - 1] * 9;
      }
      dp_less[i][j] += dp_less[i - 1][j];
      if (now > 0) {
        dp_less[i][j] += dp_equal[i - 1][j];
        if (j >= 1) {
          dp_less[i][j] += dp_equal[i - 1][j - 1] * (now - 1);
        }
      }
    }
  }
  cout << dp_equal[N][K] + dp_less[N][K] << endl;
}
