#include <bits/stdc++.h>
using namespace std;
template <class T>
bool uin(T &a, T b) {
  return a > b ? (a = b, true) : false;
}
template <class T>
bool uax(T &a, T b) {
  return a < b ? (a = b, true) : false;
}
string s;
long long k, ans = 0;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.precision(10);
  cout << fixed;
  cin >> s;
  long long len = long long(s.size());
  long long n1 = -1, n2 = -1, n3 = -1, p2 = -1, p3 = -1;
  n1 = s[0] - '0';
  for (int i = 1; i < len; ++i) {
    if (s[i] != '0') {
      n2 = s[i] - '0';
      p2 = i + 1;
      break;
    }
  }
  if (p2 != -1) {
    for (int i = p2; i < len; ++i) {
      if (s[i] != '0') {
        n3 = s[i] - '0';
        p3 = i + 1;
        break;
      }
    }
  }
  cin >> k;
  if (k > len) {
    cout << 0 << '\n';
    return 0;
  }
  long long tot = 0;
  long long no = 0;
  if (k == 1) tot = len * 9;
  if (k == 2) {
    tot = len * (len - 1) / 2 * 9 * 9;
  }
  if (k == 3) {
    tot = len * (len - 1) * (len - 2) / 6 * 9 * 9 * 9;
  }
  if (k == 1) {
    no += (9 - n1);
  }
  if (k == 2) {
    no += (9 - n1) * (len - 1) * 9;
    if (n2 == -1) {
      no += (len - 1) * 9;
    } else {
      no += (p2 - 2) * 9;
      no += (9 - n2);
    }
  }
  if (k == 3) {
    no += (9 - n1) * (len - 1) * (len - 2) / 2 * 9 * 9;
    if (n3 == -1) {
      no += ((p2 - 2) * 9 + (9 - n2 + 1)) * (len - p2) * 9;
    } else {
      no += ((p2 - 2) * 9 + (9 - n2)) * ((len - p2) * 9) +
            ((p3 - p2 - 1) * 9 + (9 - n3));
    }
  }
  cout << (tot - no) << '\n';
  return 0;
}
