#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
const long long INF = 1e15;
using Graph = vector<vector<long long>>;
signed main() {
  string N;
  cin >> N;
  long long K;
  cin >> K;
  long long dp[110][2][6];
  dp[0][0][0] = 1;
  for (long long i = 0; i < N.size(); i++) {
    for (long long k = 0; k < K; k++) {
      dp[i + 1][1][k + 1] += dp[i][1][k] * 9;
      dp[i + 1][1][k] += dp[i][1][k];
      long long NX = N.at(i) - '0';
      dp[i + 1][1][k] += dp[i][0][k];
      for (long long n = 1; n < NX; n++) {
        dp[i + 1][1][k + 1] += dp[i][0][k];
      }
      if (NX == 0)
        dp[i + 1][0][k] += dp[i][0][k];
      else
        dp[i + 1][0][k + 1] += dp[i][0][k];
    }
  }
  long long A = (long long)N.size();
  cout << dp[A][0][K] + dp[A][1][K] << endl;
}
