#include <bits/stdc++.h>
using namespace std;
template <class T>
inline void amin(T &x, const T &y) {
  if (y < x) x = y;
}
template <class T>
inline void amax(T &x, const T &y) {
  if (x < y) x = y;
}
template <class Iter>
void rprintf(const char *fmt, Iter begin, Iter end) {
  for (bool sp = 0; begin != end; ++begin) {
    if (sp)
      putchar(' ');
    else
      sp = true;
    printf(fmt, *begin);
  }
  putchar('\n');
}
const int SIZE = 65536;
long long H[SIZE];
char S[15];
void MAIN() {
  for (int i = 0, i_len = (SIZE); i < i_len; ++i) H[i] = (long long)i * i;
  scanf("%s", S);
  int len = strlen(S);
  int ans = -1;
  for (int s = 0, s_len = (1 << len); s < s_len; ++s) {
    if (s == 0) continue;
    int top = -1;
    int cnt = 0;
    int r = 0;
    for (int i = 0, i_len = (len); i < i_len; ++i)
      if (s >> i & 1) {
        if (top == -1) top = S[i] - '0';
        cnt++;
        r = r * 10 + S[i] - '0';
      }
    if (top == 0) continue;
    if (r == 0) continue;
    int k = lower_bound(H, H + SIZE, (long long)r) - H;
    if (k < SIZE && H[k] == r) {
      if (ans == -1 || ans > len - cnt) ans = len - cnt;
    }
  }
  printf("%d\n", ans);
}
int main() {
  int TC = 1;
  for (int tc = 0, tc_len = (TC); tc < tc_len; ++tc) MAIN();
  return 0;
}
