#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
const long long INF = 1e16;
const long double EPS = 1e-10;
const long 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<long long, long long> fd[] = {make_pair(1, 0), make_pair(-1, 0),
                                         make_pair(0, 1), make_pair(0, -1)};
string n;
long long k;
vector<long long> vec;
long long dp[200][2][4];
signed main() {
  cin >> n >> k;
  for (long long i = (0); i < (n.length()); i++) {
    vec.push_back((long long)(n[i] - '0'));
  }
  dp[0][1][0] = 1LL;
  for (long long i = (0); i < (n.length()); i++) {
    for (long long j = (0); j < (k + 1); j++) {
      (vec[i] == 0 ? dp[i + 1][1][j] : dp[i + 1][1][j + 1]) += dp[i][1][j];
      dp[i + 1][0][j + 1] +=
          dp[i][0][j] * 9 + dp[i][1][j] * max(0LL, vec[i] - 1);
      dp[i + 1][0][j] += dp[i][1][j] * (vec[i] > 0) + dp[i][0][j];
    }
  }
  cout << dp[n.length()][1][k] + dp[n.length()][0][k] << endl;
}
