#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
using p = pair<int, int>;
using pl = pair<ll, ll>;
using v = vector<int>;
using vd = vector<double>;
using vs = vector<string>;
using vl = vector<ll>;
int main() {
  string ns;
  int k;
  cin >> ns >> k;
  int d = ns.size();
  vector<vl> dp0(d, vector<ll>(k + 1, 0));
  vector<vl> dp1(d, vector<ll>(k + 1, 0));
  dp0[0][1] = 1;
  dp1[0][1] = ns[0] - '0' - 1;
  dp1[0][0] = 1;
  for (int i = 0; i < d - 1; i++) {
    for (int j = 1; j < k + 1; j++) {
      if (ns[i + 1] == '0') dp0[i + 1][j] = dp0[i][j];
      if (ns[i + 1] != '0') dp0[i + 1][j] = dp0[i][j - 1];
    }
    for (int j = 1; j <= k; j++) {
      if (dp0[i][j] == 1) {
        if (j < k) dp1[i + 1][j + 1] = dp0[i][j] * (ns[i + 1] - '0' - 1);
        dp1[i + 1][j] = dp0[i][j];
      }
    }
    dp1[i][0] = 1;
    for (int j = 1; j < k + 1; j++) {
      dp1[i + 1][j] += dp1[i][j - 1] * 9 + dp1[i][j];
    }
  }
  cout << dp0[d - 1][k] + dp1[d - 1][k] << endl;
}
