#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, K;
  cin >> N >> K;
  int cnt = 0;
  for (int i = 1; i <= N; i++) {
    int m = 0, rem = 0;
    while (i >= 0) {
      rem = i % 10;
      if (rem != 0) m++;
      i /= 10;
    }
    if (m == K) cnt++;
  }
  cout << cnt << endl;
}
