#include <bits/stdc++.h>
using namespace std;
int n;
int dl;
int zlicz(int n1, int a) {
  int b = a;
  int i;
  for (i = 1; b; i++) b /= 10;
  while (n1 && a) {
    if (a % 10 == n1 % 10) a /= 10;
    n1 /= 10;
  }
  if (a > 0)
    return 12345678;
  else
    return (dl - i);
}
int main() {
  scanf("%d", &n);
  int n2 = n;
  for (dl = 1; n2; dl++) n2 /= 10;
  int wyn = 12345678;
  zlicz(n, 81);
  for (int i = 1; i * i <= n; i++) wyn = min(wyn, zlicz(n, i * i));
  if (wyn != 12345678)
    printf("%d", wyn);
  else
    printf("-1");
}
