#include <bits/stdc++.h>
using namespace std;
int main() {
  long long t, k;
  cin >> t >> k;
  int n, m, sum = 0;
  while (t--) {
    n = t % 10;
    m = t / 10;
    if (k == 1) {
      if (n == 0 || m == 0) {
        sum++;
      }
    } else if (k == 2) {
      if (n != 0 && m != 0) {
        sum++;
      }
    } else {
      if (n > 9 || m > 9) {
        sum++;
      }
    }
  }
  if (k == 2) {
    cout << sum + 1 << endl;
    return 0;
  }
  cout << sum << endl;
  return 0;
}
