#include <bits/stdc++.h>
using namespace std;
int sz;
map<int, int> m;
void gera() {
  for (int i = 0; i <= 45000; i++) {
    m[i * i] = 1;
  }
}
int resp = 1000;
void go(string n) {
  int num = 0;
  int fat = 1;
  int qtd = 0;
  int zero = 0;
  for (int i = sz - 1; i >= 0; i--) {
    if (n[i] != 'X') {
      if (n[i] == '0')
        zero = 1;
      else
        zero = 0;
      num += (n[i] - '0') * fat;
      fat *= 10;
    } else {
      qtd++;
    }
  }
  if (qtd == sz) {
    return;
  }
  if (!zero && num != 0 && m[num] == 1) {
    resp = min(resp, qtd);
  }
  string nv = n;
  for (int i = 0; i < sz; i++) {
    if (nv[i] != 'X') {
      char aux = nv[i];
      nv[i] = 'X';
      go(nv);
      nv[i] = aux;
    }
  }
}
int main() {
  gera();
  string n;
  ios::sync_with_stdio(false);
  cin >> n;
  sz = n.size();
  go(n);
  if (resp == 1000) {
    printf("-1\n");
  } else {
    printf("%d\n", resp);
  }
  return 0;
}
