#include <bits/stdc++.h>
using namespace std;
int main() {
  {
    string s;
    long long k;
    cin >> s >> k;
    long long c = 0, c1 = 0;
    for (long long i = s.length() - 1; i >= 0; i--) {
      if (s[i] == '0')
        c++;
      else {
        c1++;
      }
      if (c == k) break;
    }
    if (c == k)
      cout << c1 << "\n";
    else
      cout << s.length() - 1 << "\n";
  }
}
