#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr ll MOD = 1e9 + 7;
constexpr ll INF = 1e18;
int main() {
  ll n, m, i, j, k;
  string s;
  cin >> s;
  cin >> k;
  string t;
  t = s;
  function<ll(string, int)> dfs = [&](string x, ll cnt) {
    ll ret = 0;
    if (cnt > k || x.size() > t.size()) {
      return ret;
    }
    if (cnt == k && x.size() == t.size() && x <= t) {
      ret++;
      return ret;
    }
    if (x.size() == t.size()) return ret;
    for (char p = '0'; p <= '9'; p++) {
      if (p == '0') {
        ret += dfs(x + p, cnt);
      } else {
        ret += dfs(x + p, cnt + 1);
      }
    }
    return ret;
  };
  cout << dfs("", 0) << endl;
  return 0;
}
