#include <bits/stdc++.h>
using namespace std;
using vec_int = vector<long long>;
using P = pair<long long, long long>;
using T = tuple<long long, long long, long long>;
using ll = long long;
long long charToInt(char c) {
  char zero_num = '0';
  return (long long)c - (long long)zero_num;
}
long long combination(long long N, long long c) {
  long long temp = 1;
  for (long long i = 0; i < c; i++) {
    temp = temp * (N - i);
  }
  for (long long i = 0; i < c; i++) {
    temp = temp / (1 + i);
  }
  return temp;
}
signed main() {
  string N;
  long long K;
  cin >> N;
  cin >> K;
  long long len = N.size();
  long long DP1[len][K + 1];
  long long DP2[len][K + 1];
  for (long long i = 0; i < len; i++) {
    for (long long j = 0; j < K + 1; j++) {
      DP1[i][j] = 0;
      DP2[i][j] = 0;
    }
  }
  DP1[0][0] = 1;
  DP1[0][1] = charToInt(N.at(0)) - 1;
  DP2[0][1] = 1;
  for (long long i = 1; i < len; i++) {
    for (long long j = 0; j < K + 1; j++) {
      if (j > 0) {
        DP1[i][j] = DP1[i - 1][j - 1] * 9 + DP1[i - 1][j] +
                    (DP2[i - 1][j - 1] * (charToInt(N.at(i)) - 1)) +
                    DP2[i - 1][j];
      } else {
        DP1[i][j] = DP1[i - 1][j] + (DP2[i - 1][j]);
      }
    }
    for (long long j = 0; j < K + 1; j++) {
      if (j > 0) {
        DP2[i][j] = DP2[i - 1][j - 1];
        if (charToInt(N.at(i)) == 0) {
          DP2[i][j] += DP2[i - 1][j];
        }
      } else {
        if (charToInt(N.at(i)) == 0) {
          DP2[i][j] += DP2[i - 1][j];
        }
      }
    }
  }
  for (long long i = 0; i < len; i++) {
    for (long long j = 0; j < K + 1; j++) {
    }
  }
  cout << DP1[len - 1][K] + DP2[len - 1][K] << endl;
  return 0;
}
