#include <bits/stdc++.h>
using namespace std;
const long long N = 101;
long long dp[N][4][2];
signed main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  string n;
  cin >> n;
  long long k;
  cin >> k;
  long long answer = 0;
  for (long long j = 1; j < (long long)(n).size(); ++j) {
    if (j < k) continue;
    if (k == 1) answer += 1ll * 9;
    if (k == 2) answer += 1ll * 9 * (j - 1) * 9;
    if (k == 3) answer += 1ll * 9 * (j - 1) * (j - 2) / 2 * 9 * 9;
  }
  dp[1][1][0] = (n[0] - '0' - 1);
  dp[1][1][1] = 1;
  for (long long i = 2; i <= (long long)(n).size(); ++i) {
    for (long long j = 0; j < 4; ++j) {
      dp[i][j][0] = dp[i - 1][j][0];
      if (n[i - 1] == '0')
        dp[i][j][1] = dp[i - 1][j][1];
      else
        dp[i][j][0] += dp[i - 1][j][1];
    }
    for (long long done = 1; done < k; ++done) {
      dp[i][done + 1][0] += 9 * dp[i - 1][done][0];
      dp[i][done + 1][0] += (n[i - 1] - '0' - 1) * dp[i - 1][done][1];
      if (n[i - 1] != '0') dp[i][done + 1][1] += dp[i - 1][done][1];
    }
  }
  answer += dp[(long long)(n).size()][k][0] + dp[(long long)(n).size()][k][1];
  cout << answer;
  return 0;
}
