#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
long long ncr(long long n, long long k) {
  long long res = 1;
  if (k > n - k) k = n - k;
  for (long long i = 0; i < k; ++i) {
    res *= (n - i);
    res /= (i + 1);
  }
  return res;
}
void solve() {
  ll n, k, ans = 0;
  string s;
  cin >> s >> k;
  n = s.size();
  ll cur = pow(9, k);
  if (n >= k + 1) ans = ans + ncr(n - 1, k) * cur;
  cur = s[0] - '0';
  if (k == 1) {
    ans = ans + cur;
  }
  if (k == 2) {
    ans = ans + 9 * (n - 1) * (cur - 1);
    for (long long i = 1; i < n; i++) {
      ans = ans + (s[i] - '0');
    }
  }
  if (k == 3) {
    for (long long i = 1; i < n; i++) {
      if (s[i] == '0') continue;
      ans = ans + 9 * (n - i - 1) * (s[i] - '1') * cur;
      for (long long j = i + 1; j < n; j++) {
        if (s[j] == '0') continue;
        ans = ans + (s[i] - '0') * (s[j] - '0');
      }
    }
  }
  cout << ans;
}
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ll t;
  t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
