#include <bits/stdc++.h>
using namespace std;
using ii = pair<int, int>;
using vi = vector<int>;
using vii = vector<ii>;
using vvi = vector<vi>;
using ll = long long int;
const int MOD = 1000 * 1000 * 1000 + 7;
ll cont(string& num, int idx, int kact, vector<vvi>& m, int s) {
  if (kact == 0)
    return 1;
  else if (idx == num.size() && kact > 0)
    return 0;
  else if (m[idx][kact][s] != -1)
    return m[idx][kact][s];
  else if (s == 0) {
    ll soluciones = 0;
    if (num[idx] != '0') {
      soluciones += cont(num, idx + 1, kact - 1, m, 0);
      soluciones += (num[idx] - '0' - 1) * cont(num, idx + 1, kact - 1, m, 1);
    }
    soluciones += cont(num, idx + 1, kact, m, 1);
    m[idx][kact][s] = soluciones;
    return soluciones;
  } else {
    ll soluciones = 0;
    soluciones += 9 * cont(num, idx + 1, kact - 1, m, 1);
    soluciones += cont(num, idx + 1, kact, m, 1);
    m[idx][kact][s] = soluciones;
    return soluciones;
  }
}
bool res() {
  string s;
  int k;
  cin >> s >> k;
  if (!cin) return false;
  vector<vvi> m(s.size() + 1, vvi(k + 1, vi(2, -1)));
  ll sol = cont(s, 0, k, m, 0);
  cout << sol << '\n';
  return true;
}
int main() {
  while (res()) {
  }
  return 0;
}
