#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
using vl = vector<ll>;
using vvl = vector<vl>;
using pll = pair<ll, ll>;
using vll = vector<pll>;
const int inf = (1 << 28);
const ll infl = (1LL << 60);
const int mod = 1e9 + 7;
int main() {
  string str;
  cin >> str;
  int k;
  cin >> k;
  int n = str.length();
  vvl dp(n, vl(4, 0));
  dp[0][0] = str[0] - '0';
  for (int i = 0; i < n - 1; ++i) {
    dp[i + 1][0] = 9;
    for (int j = 0; j < 3; ++j) {
      if (dp[i][j] == 0) continue;
      dp[i + 1][j] += dp[i][j];
      if (dp[i][j + 1] == 0)
        dp[i + 1][j + 1] += 9 * (dp[i][j] - 1) + (str[i + 1] - '0');
      else
        dp[i + 1][j + 1] += 9 * dp[i][j];
    }
  }
  cout << dp[n - 1][k - 1] << endl;
  return 0;
}
