#include <bits/stdc++.h>
using namespace std;
long long ans = -1;
void find(char s[11]) {
  long long z = atol(s);
  if (!z || s[0] == '0' || s[0] == '\0') return;
  long long rt = sqrt(z);
  while (rt * rt <= z) rt++;
  rt--;
  if (z && rt * rt == z) {
    ans = max(ans, (long long)strlen(s));
    return;
  }
  long long i = 0;
  for (i = 0; s[i] != '\0'; i++) {
    char s2[11];
    strncpy(s2, s, i);
    strncpy(&s2[i], &s[i + 1], strlen(s) - i - 1);
    s2[(long long)strlen(s) - 1] = '\0';
    find(s2);
  }
}
int main() {
  long long i = 0, j = 0;
  char s[11], s2[11];
  scanf("%s", s);
  ;
  strcpy(s2, s);
  find(s);
  if (ans == -1)
    printf("-1\n");
  else {
    ;
    printf("%lld\n", (long long)strlen(s) - ans);
  }
  return 0;
}
