#include <bits/stdc++.h>
using namespace std;
long long MOD = 1000000007;
struct edge {
  long long to, cost;
};
long long modpow(long long a, long long x) {
  if (a < 0) a += MOD;
  long long ans = 1;
  while (x > 0) {
    if (x & 1) ans = ans * a % MOD;
    a = a * a % MOD;
    x >>= 1;
  }
  return ans;
}
long long gyaku(long long n) { return modpow(n, MOD - 2); }
map<long long, long long> factor(long long n) {
  map<long long, long long> res;
  for (long long i = 2; i * i <= n; i++) {
    for (; n % i == 0; n /= i) res[i]++;
  }
  if (n > 1) res[n]++;
  return res;
}
signed main() {
  string s;
  cin >> s;
  long long n;
  n = s.size();
  long long k;
  cin >> k;
  long long dp[100][4][2];
  for (long long i = 0; i < (long long)(100); i++)
    for (long long j = 0; j < (long long)(4); j++)
      for (long long k = 0; k < (long long)(2); k++) dp[i][j][k] = 0;
  dp[0][1][1] = s[0] - '0' - 1;
  dp[0][0][1] = 1;
  dp[0][1][0] = 1;
  for (long long i = 0; i < (long long)(n - 1); i++) {
    if (s[i + 1] != '0') {
      dp[i + 1][0][1] = dp[i][0][1];
      for (long long j = 1; j < 4; j++) {
        dp[i + 1][j][1] = dp[i][j][1] + dp[i][j - 1][1] * 9 + dp[i][j][0] +
                          dp[i][j - 1][0] * (s[i + 1] - '0' - 1);
        dp[i + 1][j][0] = dp[i][j - 1][0];
      }
    } else {
      dp[i + 1][0][1] = dp[i][0][1];
      for (long long j = 1; j < 4; j++) {
        dp[i + 1][j][1] = dp[i][j][1] + dp[i][j - 1][1] * 9 + dp[i][j][0] +
                          dp[i][j - 1][0] * (s[i + 1] - '0');
        dp[i + 1][j][0] = dp[i][j][0];
      }
    }
  }
  cout << dp[n - 1][k][0] + dp[n - 1][k][1] << endl;
}
