#include <bits/stdc++.h>
using namespace std;
struct cww {
  cww() {
    ios::sync_with_stdio(false);
    cin.tie(0);
  }
} star;
const long long INF = numeric_limits<long long>::max();
template <class T>
bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
long long Pow(long long x, long long n) {
  long long ret = 1;
  while (n > 0) {
    if (n & 1) ret *= x;
    x *= x;
    n >>= 1;
  }
  return ret;
}
long long combination(long long N, long long R) {
  if (R < 0 || R > N) return 0;
  if (R == 1)
    return N;
  else if (R == 2)
    return N * (N - 1) / 2;
  else
    return N * (N - 1) * (N - 2) / 6;
}
vector<vector<vector<long long>>> memo;
string N;
int K, keta;
long long solve(int i, int k, bool smaller) {
  if (memo[i][k][smaller] != -1) {
    return memo[i][k][smaller];
  }
  if (k == 0) {
    memo[i][k][smaller] = 1;
    return 1;
  }
  if (i == keta) {
    memo[i][k][smaller] = 0;
    return 0;
  }
  if (smaller) {
    memo[i][k][smaller] = combination(keta - i, k) * pow(9, k);
    return memo[i][k][smaller];
  }
  if (N[i] == '0') {
    memo[i][k][smaller] = solve(i + 1, k, smaller);
    return memo[i][k][smaller];
  }
  long long zero = solve(i + 1, k, true);
  long long mid = solve(i + 1, k - 1, true) * (N[i] - '1');
  long long girigiri = solve(i + 1, k - 1, false);
  memo[i][k][smaller] = zero + mid + girigiri;
  return memo[i][k][smaller];
}
int main() {
  cin >> N;
  cin >> K;
  keta = N.size();
  memo.resize(keta, vector<vector<long long>>(5, vector<long long>(2, -1)));
  cout << solve(0, K, false);
  return 0;
}
