#include <bits/stdc++.h>
using namespace std;
const int N = 20000;
std::vector<int> fact(3000, 1);
int k;
string n;
int pow(int a, int b) {
  int ans = 1;
  while (b) {
    if (b & 1) ans = (ans * a);
    b /= 2;
    a = (a * a);
  }
  return ans;
}
int nCr(int x, int y) {
  if (y > x) return 0;
  if (y == 0) return 1;
  if (x == y) return 1;
  if (x == 0 && y == 0) return 1;
  if (y == 1) return x;
  if (y == 2) {
    return x * (x - 1) / (2);
  }
  if (y == 3) {
    return x * (x - 1) * (x - 2) / (6);
  }
}
int fu(string s, int k) {
  if (k <= 0) return 1;
  int len = int((s).size());
  if (len == 0) return 1;
  int tmp, tmp2, tmp3;
  tmp = tmp3 = tmp2 = 0;
  tmp2 = 1;
  if (k > len) return 0;
  tmp = nCr(len - 1, k) * (pow(9, k));
  tmp3 = (s[0] - '0' - 1) * (nCr(len - 1, k - 1)) * (pow(9, k - 1));
  if (len >= 1) {
    string s2 = s.substr(1);
    tmp2 = (fu(s2, k - 1));
  }
  return tmp2 + tmp3 + tmp;
}
int main() {
  cin >> n >> k;
  int ans = fu(n, k);
  cout << ans << endl;
}
