#include <bits/stdc++.h>
int n, c[20], cnt, k, sum, min = 13;
void f(int x, int y, int z) {
  sum = z + x;
  if (x < 0) {
    int a = sqrt(y);
    if (a * a == y && y != 0) {
      min = min > z ? z : min;
      cnt = 1;
    }
    return;
  }
  if (c[x] != 0 || (sum != k - 1)) f(x - 1, y * 10 + c[x], z);
  f(x - 1, y, z + 1);
}
int main() {
  scanf("%d", &n);
  while (n > 0) {
    c[k++] = n % 10;
    n /= 10;
  }
  f(k - 1, 0, 0);
  if (!cnt) {
    printf("-1");
    return 0;
  }
  printf("%d", min);
}
