#include <bits/stdc++.h>
using ll = long long;
using ull = unsigned long long;
using namespace std;
int dp[101][4][2];
int main() {
  string s;
  int k;
  cin >> s >> k;
  int n = s.size();
  vector<int> data(n);
  for (int i = int(0); i < int(n); i += 1) data[i] = s[i] - '0';
  dp[0][0][0] = 1;
  for (int i = int(0); i < int(n); i += 1) {
    for (int j = int(0); j < int(4); j += 1) {
      dp[i + 1][j][1] += dp[i][j][1];
      if (j + 1 < 4) dp[i + 1][j + 1][1] += dp[i][j][1] * 9;
      if (data[i] > 0) {
        dp[i + 1][j][1] += dp[i][j][0];
        if (j + 1 < 4) {
          dp[i + 1][j + 1][1] += dp[i][j][0] * (data[i] - 1);
          dp[i + 1][j + 1][0] += dp[i][j][0];
        }
      } else {
        dp[i + 1][j][0] += dp[i][i][0];
      }
    }
  }
  int ans = dp[n][k][0] + dp[n][k][1];
  cout << ans << endl;
}
