#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  int k;
  cin >> k;
  int n = s.size();
  long long ans = 0;
  long long t = 9;
  vector<vector<vector<long long>>> dp(
      n + 1, vector<vector<long long>>(2, vector<long long>(4, 0)));
  for (long long i = 1; i <= n; i++) {
    dp[i][0][0] = 1;
    dp[i][0][1] = (i - 1) * t;
    dp[i][0][2] = (i - 1) * (i - 2) * t * t / 2;
    dp[i][0][3] = (i - 1) * (i - 2) * (i - 3) * t * t * t / 6;
  }
  long long c = 0;
  for (int i = 1; i <= n; i++) {
    long long m = s[i - 1] - '0';
    if (m == 0) {
      continue;
    }
    ans += (m - 1) * dp[n - i + 1][0][k - 1 - c];
    ans += dp[n - i + 1][0][k - c];
    c++;
    if (k - 1 - c < 0) {
      break;
    }
  }
  cout << ans + 1 << endl;
}
