#include <bits/stdc++.h>
using namespace std;
signed main() {
  string n;
  int k;
  cin >> n >> k;
  int a[n.length()];
  for (int i = 0; i < n.length(); i++) {
    a[i] = n[i] - '0';
    if (a[i] == 0) a[i] = 0;
  }
  int dp[101][4] = {};
  int l = n.length();
  dp[1][1] = a[0];
  for (int i = 1; i < l; i++) {
    dp[i + 1][1] = dp[i][1] + 9;
  }
  dp[2][2] = (dp[1][1] - 1) * 9 + a[1];
  for (int i = 2; i < l; i++) {
    dp[i + 1][2] = dp[i][1] * 9 + dp[i][2];
    if (a[i] == 0) dp[i + 1][2] = (dp[i][1] - 1) * 9 + dp[i][2];
  }
  dp[3][3] = (dp[2][2] - 1) * 9 + a[2];
  if (a[2] == 0) dp[3][3] = (dp[2][2] + 1) * 9;
  for (int i = 3; i < l; i++) {
    dp[i + 1][3] = dp[i][2] * 9 + dp[i][3];
    if (a[i] == 0) dp[i + 1][3] = (dp[i][2] - 1) * 9 + dp[i][3];
  }
  cout << dp[n.length()][k] << endl;
}
