#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e5 + 5;
const long long MOD = 1e9 + 7;
long long qpow(long long a, long long b) {
  long long ans = 1;
  while (b) {
    if (b & 1) ans *= a;
    a *= a;
    b >>= 1;
  }
  return ans;
}
long long comb(int m, int n) {
  long long up = 1, down = 1;
  for (int i = (m - n + 1); i <= (m); i++) up *= i;
  for (int i = (1); i <= (n); i++) down *= i;
  return up / down;
}
int main() {
  string n;
  long long k, ans;
  cin >> n >> k;
  int len = n.size();
  ans = qpow(9ll, k) * comb(len - 1, k);
  if (k == 1)
    ans += n[0] - '0';
  else if (k == 2) {
    ans += (n[0] - '1') * comb(len - 1, 1) * 9;
    int x = 1;
    while (x < len && n[x++] == '0')
      ;
    ans += comb(len - x, 1) * 9;
    ans += n[x - 1] - '0';
  } else {
    ans += (n[0] - '1') * comb(len - 1, 2) * 9 * 9;
    for (int i = (1); i <= (len - 2); i++) {
      if (n[i] != '0') {
        ans += (n[0] - '1') * comb(len - i - 1, 1) * 9;
        int x = i + 1;
        while (x < len && n[x++] == '0')
          ;
        ans += comb(len - x, 1) * 9;
        ans += n[x - 1] - '0';
      }
    }
  }
  cout << ans << endl;
  return 0;
}
