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