#include <bits/stdc++.h>
using namespace std;
string n;
int k, d;
int count_ans(string s) {
  int e = s.size();
  cerr << "s : " << s << " ";
  if (e < d) {
    return pow(10, k) - 1;
  } else if (e == d) {
    int ret = n.at(0) - '1';
    ret *= (pow(10, k - 1) - 1);
    cerr << "ret1 : " << ret << " ";
    int tmp = 1;
    for (int i = 1; i < d; i++) {
      if (s.at(i) == '1') {
        tmp *= n.at(i) - '0';
      }
    }
    cerr << "tmp : " << tmp << " ";
    ret += tmp;
    return ret;
  }
}
int dfs(string s, int l) {
  int e = s.size();
  int sum = 0;
  if (l == k) {
    sum += count_ans(s);
  }
  cerr << sum << endl;
  if (l > k || e >= d) {
    return sum;
  }
  sum += dfs(s + '0', l);
  sum += dfs(s + '1', l + 1);
  return sum;
}
int main() {
  cin >> n >> k;
  d = n.size();
  int res = dfs("1", 1);
  cout << res << endl;
  return 0;
}
