#include <bits/stdc++.h>
using namespace std;
long long int bexp(long long int a, long long int b) {
  long long int res = 1;
  while (b) {
    if (b & 1) res = (res * a);
    a = (a * a);
    b >>= 1;
  }
  return res;
}
long long int gcd(long long int a, long long int b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
long long int ncr(long long int n, long long int r) {
  if (n < r)
    return 0;
  else if (r == 0)
    return 1;
  else if (r == 1)
    return n;
  else if (r == 2)
    return (n * (n - 1)) / 2;
  else
    return (n * (n - 1) * (n - 2)) / 6;
}
string s;
long long int r, n;
long long int solve(long long int m, long long int r) {
  long long int ans = ncr(m - 1, r - 1) * bexp(9, r - 1) * (s[n - m] - '0') +
                      ncr(m - 1, r) * bexp(9, r);
  long long int p = 1;
  for (long long int i = 0; i < r - 1; ++i) {
    while (p < n && s[p] == '0') {
      p++;
    }
    if (p == n) break;
    ans -= ncr(n - p, r - i - 2) * bexp(9, r - i - 2) * (9 - s[p] + '0');
  }
  return ans;
}
int32_t main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.precision(10);
  cin >> s >> r;
  n = s.size();
  cout << solve(n, r);
  return 0;
}
