#include <bits/stdc++.h>
int root(int x);
int main() {
  int number;
  scanf("%d", &number);
  int n = number;
  int dig = 0, num[10], i = 0;
  int d = 0, r[10], m = 0;
  int ans, p;
  while (number > 0) {
    num[i] = number % 10;
    number = number / 10;
    dig++;
    i++;
  }
  i = 0;
  root(n);
  if (root(n) == 0) {
    printf("0");
  } else if (root(n) == 1) {
    for (int j = (sqrt(n) / 2); j >= 0; j--) {
      i = 0;
      p = (j * j);
      d = 0;
      while (p > 0) {
        r[i] = p % 10;
        p = p / 10;
        d++;
        i++;
      }
      m = 0;
      for (int k = 0; k < dig; k++) {
        if (r[m] == num[k]) {
          m++;
          if (m == d) {
            ans = dig - d;
            printf("%d", ans);
            return 0;
          }
        }
      }
    }
    printf("-1");
  }
  return 0;
}
int root(int x) {
  float y;
  y = sqrt(x);
  int a = sqrt(x);
  float b = a;
  if (y == b) {
    return 0;
  } else {
    return 1;
  }
}
