#include <bits/stdc++.h>
using namespace std;
using namespace std::chrono;
const int mod = 1000000007ll;
const int smod = 998244353ll;
const int inf = 1000000007;
const double eps = 1e-8;
const int MAXN = 300004;
string n;
int k;
int solve(string n, int k) {
  if (k == 0) {
    return 1;
  }
  if (k > n.size()) {
    return 0;
  }
  int R = 0;
  for (int i = n.size() - 1; i >= 0; i--) {
    string t = n.substr(i + 1);
    if (i) {
      if (t.size() > 0) {
        t[0] = '9';
      }
      R += 9 * solve(t, k - 1);
    } else {
      R += solve(t, k - 1);
      if (t.size() > 0) {
        t[0] = '9';
      }
      R += (n[i] - '1') * solve(t, k - 1);
    }
  }
  return R;
}
int main(int argc, char* argv[]) {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cout.precision(15);
  cout.setf(ios::fixed);
  cin >> n >> k;
  int R = 0;
  R = solve(n, k);
  cout << R << endl;
  return 0;
}
