#include <bits/stdc++.h>
using namespace std;
const long long MAX = 1000001;
const long long MOD = 1000000007;
signed main() {
  string no;
  long long n0, k, n;
  cin >> no >> k;
  reverse(no.begin(), no.end());
  long long m = 1, t = no.size() - 1, ans = 0, p;
  for (long long i = k; i > 0; i--) {
    while (t >= 0 && no[t] == '0') t--;
    if (i == 3) {
      ans += t * (t - 1) * (t - 2) * 729 / 6;
      ans += t * (t - 1) * 81 * ((long(no[t] - '0') - 1)) / 2;
    }
    if (i == 2) {
      ans += t * (t - 1) * 81 / 2;
      ans += t * 9 * (long(no[t] - '0') - 1);
    }
    if (i == 1) {
      ans += t * 9;
      ans += ((long(no[t] - '0')));
    }
    t--;
  }
  cout << ans;
}
