#include <bits/stdc++.h>
using namespace std;
string N;
long long K;
long long dp[101][4][2];
signed main() {
  cin >> N >> K;
  long long size = N.size();
  dp[0][0][0] = 1;
  dp[0][0][1] = 1;
  dp[0][1][0] = 9;
  dp[0][1][1] = N[size - 1] - '0';
  dp[0][2][0] = 0;
  dp[0][2][1] = 0;
  dp[0][3][0] = 0;
  dp[0][3][1] = 0;
  for (long long s = 1; s < size; s++) {
    dp[s][0][0] = 1;
    dp[s][0][1] = 1;
    for (long long k = 1; k <= K; k++) {
      dp[s][k][0] = (dp[s - 1][k - 1][0] * 9) + dp[s - 1][k][0];
      long long n = N[size - s - 1] - '0';
      dp[s][k][1] = dp[s - 1][k - 1][1] +
                    (dp[s - 1][k - 1][0] * (n ? n - 1 : 0)) + dp[s - 1][k][0];
    }
  }
  cout << dp[size - 1][K][1] << endl;
}
