#include <bits/stdc++.h>
using namespace std;
static const long long INF = 1e18;
static const long long MAX = 101010;
static const long long MOD = 1e9 + 7;
int main(void) {
  long long i, j, k;
  string L;
  long long K;
  cin >> L >> K;
  long long N = L.size();
  long long dp[111][5][2] = {};
  dp[0][0][1] = 1;
  for (i = 0; i < N; i++) {
    for (j = 0; j <= K; j++) {
      for (k = 0; k < 10; k++) {
        dp[i + 1][j + (k == 0)][0] += dp[i][j][0];
      }
      long long MX = L[i] - '0';
      for (k = 0; k < MX; k++) {
        dp[i + 1][j + (k == 0)][0] += dp[i][j][1];
      }
      dp[i + 1][MX + (k == 0)][1] += dp[i][j][1];
    }
  }
  cout << dp[N][K][0] + dp[N][K][1] << "\n";
}
