#include <bits/stdc++.h>
using namespace std;
long long comb(int n, int r) {
  vector<vector<long long>> v(n + 1, vector<long long>(n + 1, 0));
  for (int i = 0; i < v.size(); i++) {
    v[i][0] = 1;
    v[i][i] = 1;
  }
  for (int j = 1; j < v.size(); j++) {
    for (int k = 1; k < j; k++) {
      v[j][k] = (v[j - 1][k - 1] + v[j - 1][k]);
    }
  }
  return v[n][r];
}
int main(void) {
  int N, K;
  cin >> N;
  cin >> K;
  unsigned digit = 0;
  while (N != 0) {
    N /= 10;
    digit++;
  }
  int count = 0;
  for (int i = K; i < digit + 1; i++) {
    if (i == digit) {
    } else {
      count += 9 * comb(i - 1, K - 1);
    }
  }
  cout << count << endl;
}
