#include <bits/stdc++.h>
using namespace std;
const long long INF = 1LL << 60;
using Graph = vector<vector<int>>;
const int MAX_DIGIT = 100;
long long dp[200][2][5];
int main() {
  string n;
  int k;
  cin >> n >> k;
  dp[0][0][0] = 1;
  for (int i = 0; i < n.length(); i++) {
    for (int j = 0; j < 2; j++) {
      for (int t = 0; t < k + 1; t++) {
        int c = n[i] - '0';
        for (int now = 0; now < 10; now++) {
          if (c < now && j == 0) continue;
          int jj = j;
          int tt = t;
          if (now != 0) tt++;
          if (now < c) jj = 1;
          dp[i + 1][jj][tt] += dp[i][j][t];
          　
        }
      }
    }
  }
  long long ans = dp[n.length()][0][k] + dp[n.length()][1][k];
  cout << ans << endl;
}
