#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vd = vector<double>;
int ans = 0;
string N;
int K, L;
void dfs(string s, int c) {
  int sl = s.length();
  if (sl > L) return;
  if (c == 0) {
    if (sl < L || s <= N) ans++;
  } else if (c > 0) {
    for (int i = 1; i <= (9); i++) dfs(s + to_string(i), c - 1);
  }
  dfs(s + to_string(0), c);
}
signed main() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(20);
  cin >> N;
  cin >> K;
  L = N.length();
  for (int i = 1; i <= (9); i++) {
    dfs(to_string(i), K - 1);
  }
  cout << ans << endl;
}
