#include <bits/stdc++.h>
using namespace std;
long long dp[105][2][105];
int main() {
  string N;
  long long K;
  cin >> N >> K;
  dp[0][0][0] = 0;
  dp[0][0][1] = 1;
  dp[0][1][0] = 1;
  dp[0][1][1] = N[0] - '1';
  for (int i = 0; i < (N.length() + 1); ++i) {
    for (int j = 0; j < (101); ++j) {
      dp[i + 1][1][j + 1] += dp[i][1][j] * 9;
      dp[i + 1][1][j + 1] += dp[i][0][j] * (N[i + 1] - '0');
      dp[i + 1][1][j] += dp[i][1][j];
      dp[i + 1][1][j] += dp[i][0][j];
      if (N[i + 1] == '0') {
        dp[i + 1][0][j + 1] = 0;
        dp[i + 1][0][j] = dp[i][0][j];
      } else {
        dp[i + 1][0][j + 1] = dp[i][0][j];
        dp[i + 1][0][j] = 0;
      }
    }
  }
  cout << (dp[N.length() - 1][0][K] + dp[N.length() - 1][1][K]) << endl;
  for (int i = 0; i < (3); ++i)
    for (int j = 0; j < (3); ++j)
      for (int k = 0; k < (2); ++k)
        cout << "  [" << i << "][" << k << "][" << j << "] : " << dp[i][k][j]
             << endl;
}
