#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  int k;
  cin >> k;
  int n = s.size();
  vector<vector<vector<long long>>> dp(
      n + 1, vector<vector<long long>>(2, vector<long long>(n + 1, 0)));
  dp[0][0][0] = 1;
  for (int i = 0; i < n; ++i) {
    long long y = s[i] - '1';
    for (int f = 0; f < 2; ++f) {
      for (int g = 0; g < k + 1; ++g) {
        if (f == 0) {
          dp[i + 1][0][g + 1] += dp[i][f][g];
          if (y > 0) dp[i + 1][1][g + 1] += dp[i][f][g] * y;
          dp[i + 1][1][g] += dp[i][f][g];
        } else {
          dp[i + 1][1][g + 1] += dp[i][f][g] * 9;
          dp[i + 1][1][g] += dp[i][f][g];
        }
      }
    }
  }
  cout << dp[n][0][k] + dp[n][1][k] << "\n";
  return 0;
}
