#include <bits/stdc++.h>
using namespace std;
long long n, m, i, j, b[15], k, mi = 2147480000, s, x, g = 1;
string s1, s2;
char c[10005];
bool p_0(string s1) {
  if (s1 == "0") return 1;
  if (s1[0] == '0') return 0;
  return 1;
}
int main() {
  cin >> n >> k;
  for (i = 1; i <= k; i++) g *= 10;
  sprintf(c, " %d", n);
  s1 = c;
  m = s1.length() - 1;
  while (b[0] == 0) {
    s2 = "";
    for (j = m; j >= 1 && b[j]; j--)
      ;
    b[j] = 1;
    for (i = j + 1; i <= m; i++) b[i] = 0;
    for (i = 1; i <= m; i++)
      if (b[i]) s2 += s1[i];
    sscanf(s2.c_str(), "%d", &x);
    if (x % g == 0 && p_0(s2)) {
      s = m;
      for (i = 1; i <= m; i++) s -= b[i];
      if (s < mi) mi = s;
    }
  }
  cout << mi;
  return 0;
}
