#include <bits/stdc++.h>
using namespace std;
const long long int mod = 1e9 + 7;
long long int EX(long long int x, long long int n) {
  if (n == 0)
    return 1;
  else if (n % 2 == 1)
    return EX(x, n - 1) * x;
  else
    return EX(x * x, n / 2);
};
const long long MOD = 1000000007;
const int MAX_C = 1000;
long long Com[MAX_C][MAX_C];
void calc_com() {
  memset(Com, 0, sizeof(Com));
  Com[0][0] = 1;
  for (int i = 1; i < MAX_C; ++i) {
    Com[i][0] = 1;
    for (int j = 1; j < MAX_C; ++j) {
      Com[i][j] = (Com[i - 1][j - 1] + Com[i - 1][j]);
    }
  }
}
int main() {
  string s;
  cin >> s;
  int k;
  cin >> k;
  int n = s.size();
  long long int ans = 0;
  int first = s[0] - '0';
  calc_com();
  for (int i = k - 1; i < n - 1; i++) {
    ans += Com[i][k - 1] * EX(9, k);
  }
  if (k == 3) {
    ans += (first - 1) * 9 * 9 * Com[n - 1][2];
    for (int i = 1; i < n - 1; i++) {
      bool notz1 = false;
      for (int j = 1; j < i; j++) {
        if (s[i] != '0') notz1 = true;
      }
      for (int j = i + 1; j < n; j++) {
        bool notz2 = false;
        for (int k = i; k < j; k++) {
          if (s[k] != '0') notz2 = true;
        }
        if (notz1)
          ans += 9 * 9;
        else if (notz2)
          ans += (s[i] - '0') * 9;
        else
          ans += (s[i] - '0') * (s[j] - '0');
      }
    }
  } else if (k == 2) {
    ans += (first - 1) * 9 * (n - 1);
    for (int i = 1; i < n; i++) {
      bool notz = false;
      for (int j = 1; j < i; j++) {
        if (s[j] != '0') notz = true;
      }
      if (notz)
        ans += 9;
      else
        ans += s[i] - '0';
    }
  } else
    ans += first;
  cout << ans << endl;
}
