#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000000007;
const long long INF = 1e16;
const double EPS = 1e-10;
const double PI = 3.141592653589793;
template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
const pair<int, int> fd[] = {make_pair(1, 0), make_pair(-1, 0), make_pair(0, 1),
                             make_pair(0, -1)};
long long n, k, m[110];
long long dp[110][5][2];
signed main() {
  string s;
  cin >> s;
  long long k;
  cin >> k;
  for (long long i = (0); i < (s.length()); i++) {
    m[i] = (long long)(s[i] - '0');
  }
  n = s.length();
  for (long long i = (0); i < (110); i++)
    for (long long j = (0); j < (5); j++)
      for (long long l = (0); l < (2); l++) dp[i][j][l] = 0;
  dp[0][0][0] = 1;
  for (long long i = (0); i < (n + 1); i++) {
    for (long long j = (0); j < (k + 1); j++) {
      dp[i + 1][j][0] += dp[i][j][0] * (long long)(m[i] == 0);
      dp[i + 1][j + 1][0] += dp[i][j][0] * (m[i] != 0);
      dp[i + 1][j][1] += dp[i][j][0] * (m[i] > 0);
      dp[i + 1][j + 1][1] += dp[i][j][0] * (m[i] - 1);
      dp[i + 1][j][1] += dp[i][j][1];
      dp[i + 1][j + 1][1] += dp[i][j][1] * 9;
    }
  }
  cout << dp[n][k][0] + dp[n][k][1] << endl;
}
