#include <bits/stdc++.h>
using namespace std;
int choose(int x, int y) {
  if (y < x) return 0;
  if (x == 0) return 1;
  if (x == 1) return y;
  if (x == 2) return (y * (y - 1)) / 2;
  if (x == 3) return (y * (y - 1) * (y - 2)) / 6;
}
int lt(int x) {
  int res = 1;
  for (int i = 1; i <= x; ++i) res *= 9;
  return res;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  ;
  string s;
  cin >> s;
  int k;
  cin >> k;
  int ans = 0;
  if (s.size() < k)
    cout << 0;
  else {
    int len = s.size();
    ans += lt(k) * choose(k, len - 1);
    for (int i = 1; i <= k; ++i) {
      for (int j = 1; j < (int)s[i - 1] - '0'; ++j) {
        ans += lt(k - i) * choose(k - i, len - i);
      }
      ans += lt(k - i) * choose(k - i, len - i - 1);
    }
    int dem = 0;
    for (int i = 0; i < s.size(); ++i)
      if (s[i] != '0') dem++;
    if (dem == k) ans++;
    cout << ans;
  }
  return 0;
}
