#include <bits/stdc++.h>
using namespace std;
int k, size;
int num[101];
int64_t dp[101][2][4];
void add(int i, bool smaller, int current_k, int x) {
  int64_t now = dp[i][smaller][current_k];
  i++;
  if (x < num[i]) smaller = true;
  if (x != 0) current_k++;
  if (current_k > k) return;
  dp[i][smaller][current_k] += now;
}
void loop(int i, bool smaller, int current_k) {
  int64_t now = dp[i][smaller][current_k];
  if (now == 0) return;
  int max;
  if (smaller)
    max = 9;
  else
    max = num[i];
  for (int x = 0; x < (int)(max + 1); x++) add(i, smaller, current_k, x);
}
int main() {
  string s;
  cin >> s >> k;
  size = s.size();
  for (int i = 0; i < (int)(size); i++) num[i] = s[i] - '0';
  dp[0][0][0] = 1;
  for (int i = 0; i < (int)(size); i++)
    for (int smaller = 0; smaller < (int)(2); smaller++)
      for (int kk = 0; kk < (int)(k + 1); kk++) loop(i, smaller, kk);
  int64_t cnt = dp[size][0][k] + dp[size][1][k];
  cout << cnt << endl;
}
