#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, K, not0, A = 0;
  cin >> N >> K;
  vector<int> vec(100, 0);
  for (int i = 1; i <= N; i++) {
    int I = i, not0 = 0;
    for (int j = 0; j < 100; j++) {
      int hantei = I % 10;
      if (hantei != 0) {
        not0++;
      }
      I /= 10;
    }
    if (not0 == K) {
      A++;
    }
  }
  cout << A << endl;
}
