#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, K;
  cin >> N >> K;
  int P[N];
  int Number;
  Number = 0;
  for (int i = 1; i < N + 1; i++) {
    int X;
    X = 0;
    while (i > 0) {
      if (i % 10 > 0) {
        X = X + 1;
      }
      i = i / 10;
    }
    if (X == K) {
      Number = Number + 1;
    }
  }
  cout << Number << endl;
}
