#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <typename T>
void printVec(vector<T> vec) {
  cout << "[";
  for (auto& v : vec) {
    cout << v << ",";
  }
  cout << "]" << endl;
}
int main() {
  string n;
  int K;
  cin >> n >> K;
  int l = n.length();
  int dp[101][3][2];
  for (int i = 0; i < (101); ++i)
    for (int j = 0; j < (3); ++j)
      for (int k = 0; k < (2); ++k) dp[i][j][k] = 0;
  dp[0][0][0] = 1;
  for (int i = 0; i < (l); ++i)
    for (int j = 0; j < (K + 1); ++j)
      for (int k = 0; k < (2); ++k) {
        int nd = n[i] - '0';
        for (int d = 0; d < (10); ++d) {
          int nj = j, nk = k;
          if (d != 0) nj++;
          if (nj > K) continue;
          if (nk == 0 and d > nd) continue;
          if (nk == 0 and d < nd) nk++;
          dp[i + 1][nj][nk] += dp[i][j][k];
        }
      }
  cout << dp[l][K][0] + dp[l][K][1] << endl;
  return 0;
}
