#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using st = string;
using db = double;
using vll = vector<long long>;
using vvll = vector<vll>;
using vst = vector<st>;
using vchar = vector<char>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;
using vvpll = vector<vpll>;
ll mod = 1000000007;
ll conb(ll n, ll k) {
  if (n < k) return 0;
  ll ans = 1;
  for (int i = (int)(0); i < (int)(k); i++) ans *= (n - i);
  for (int i = (int)(1); i < (int)(k + 1); i++) ans /= i;
  return ans;
}
ll mypow(ll n, ll k) {
  ll ans = 1;
  for (int i = (int)(0); i < (int)(k); i++) ans *= n;
  return ans;
}
int main() {
  st n;
  ll k;
  cin >> n >> k;
  ll dig = n.size();
  ll ans = 0;
  ans += conb(dig - 1, k) * mypow(9, k);
  ans += conb(dig - 1, k - 1) * mypow(9, k - 1) * ((ll)n.at(0) - (ll)'1');
  if (k == 1) ans++;
  if (k > 1 && dig >= 2) {
    n = n.substr(distance(n.begin(), lower_bound(n.begin() + 1, n.end(), '1')));
    k--;
    dig = n.size();
    ans += conb(dig - 1, k) * mypow(9, k);
    ans += conb(dig - 1, k - 1) * mypow(9, k - 1) * ((ll)n.at(0) - (ll)'1');
    if (k == 1) ans++;
  }
  if (k > 1 && dig >= 2) {
    n = n.substr(distance(n.begin(), lower_bound(n.begin() + 1, n.end(), '1')));
    k--;
    dig = n.size();
    ans += conb(dig - 1, k) * mypow(9, k);
    ans += conb(dig - 1, k - 1) * mypow(9, k - 1) * ((ll)n.at(0) - (ll)'1');
    if (k == 1) ans++;
  }
  cout << ans << endl;
}
