#include <bits/stdc++.h>
using namespace std;
const long long int INF = 1 << 29;
const long long MOD = 1000000007;
inline bool maxch(int &a, int b) {
  if (a < b) {
    a = b;
    return true;
  } else
    return false;
}
int main() {
  string _n;
  int k;
  cin >> _n >> k;
  int size = _n.size();
  vector<int> n(size);
  for (int i = 0; i < (size); ++i) {
    n[i] = static_cast<int>(_n[i] - '0');
  }
  vector<vector<int>> dp1(size, vector<int>(k + 1, 0)),
      dp2(size, vector<int>(k + 1, 0));
  dp1[0][1] = 1;
  dp2[0][1] = n[0] - 1;
  dp2[0][0] = 1;
  for (int i = 0; i < (size - 1); ++i)
    for (int j = 0; j < (k + 1); ++j) {
      if (n[i] == 0) {
        dp1[i + 1][j] += dp1[i][j];
        dp2[i + 1][j] += dp2[i][j];
        if (j != k) dp2[i + 1][j + 1] += dp2[i][j] * 9;
      } else {
        if (j != k) {
          dp1[i + 1][j + 1] += dp1[i][j];
          dp2[i + 1][j + 1] += dp1[i][j] * (n[i + 1] - 1) + dp2[i][j] * 9;
        }
        dp2[i + 1][j] += dp1[i][j] + dp2[i][j];
      }
    }
  cout << dp1[size - 1][k] + dp2[size - 1][k] << endl;
}
