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