#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main() {
  int n, k;
  cin >> n >> k;
  int ans = 0;
  for (int i = 1; i <= (n); ++i) {
    string numstr = to_string(i);
    int total_count = numstr.length();
    int zero_count = count(numstr.begin(), numstr.end(), '0');
    if (total_count - zero_count == k) {
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}
