#include <bits/stdc++.h>
using namespace std;
int main() {
  string n;
  long long k;
  cin >> n >> k;
  vector<vector<long long>> dp0(n.size() + 1, vector<long long>(k + 1, 0));
  vector<vector<long long>> dp1(n.size() + 1, vector<long long>(k + 1, 0));
  dp1[0][0] = 1;
  dp0[0][0] = 0;
  for (long long i = 0; i < n.size(); i++) {
    for (long long j = 0; j <= k; j++) {
      dp0[i + 1][j] += dp0[i][j];
      if (j < k) {
        dp0[i + 1][j + 1] += dp0[i][j] * 9 + dp1[i][j] * (int(n[i] - '0') - 1);
      }
      if (j < k && n[i] != '0') {
        dp1[i + 1][j + 1] += dp1[i][j];
      }
      if (n[i] == '0') {
        dp1[i + 1][j] += dp1[i][j];
      } else {
        dp0[i + 1][j] += dp1[i][j];
      }
    }
  }
  cout << dp0[n.size()][k] + dp1[n.size()][k] << endl;
}
