#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main() {
  ll n;
  int k;
  ll tmp = 0;
  ll ans = 0;
  cin >> n;
  cin >> k;
  for (int i = 1; i < n + 1; i++) {
    int count = 0;
    int i2 = i;
    while (i2 != 0) {
      tmp = i2 % 10;
      if (tmp != 0) {
        count += 1;
      }
      i2 /= 10;
    }
    if (count == k)
      ans += 1;
    else if (count > k)
      continue;
  }
  cout << ans << endl;
}
