#include <bits/stdc++.h>
using namespace std;
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
const long long INFLL = 1LL << 60;
const int INF = 1 << 28;
void solve(int a) { cout << (a ? "Yes" : "No") << endl; }
const int MAX = 200;
const int MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAX; i++) {
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}
long long COM(int n, int k) {
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
int main() {
  string n;
  COMinit();
  int P9[] = {1, 9, 81, 81 * 9};
  int k;
  int notZ;
  long long temp = 0;
  long long ans = 0;
  cin >> n;
  cin >> k;
  int legth = n.size();
  vector<int> NZ(legth + 1, 0);
  vector<long long> dp(legth + 1, 0);
  NZ[legth] = 0;
  for (int i = legth - 1; i >= 0; i--) {
    NZ[i] = NZ[i + 1] + (n[legth - i - 1] == '0' ? 0 : 1);
  }
  if (NZ[1] == k) {
    dp[0] = 1;
  } else if (NZ[1] > k) {
    dp[0] = 0;
  } else if (NZ[1] + 1 <= k) {
    dp[0] = n[legth - 1] - '0';
  }
  ans += dp[0];
  for (int i = 1; i < legth; i++) {
    if (n[legth - i - 1] == '0') {
      dp[i] = 0;
    } else if (NZ[i + 1] == k) {
      dp[i] = 1;
    } else if (NZ[i + 1] > k) {
      dp[i] = 0;
    } else if (NZ[i + 1] + (i + 1) >= k and NZ[i + 1] <= k) {
      notZ = k - NZ[i + 1];
      dp[i] = (n[legth - i - 1] - '0') * COM(i - 1, notZ - 1) * P9[notZ - 1];
      dp[i] += COM(i - 1, notZ) * P9[notZ];
    }
    ans += dp[i];
  }
  cout << ans << endl;
}
