#include <bits/stdc++.h>
using namespace std;
const int N = 1e5, C = 2e9;
int n, dig[10], tab[N], sqr = 0, wyn = 11;
bool binsearch(int x) {
  int pocz = 1, kon = sqr;
  while (pocz <= kon) {
    int akt = (pocz + kon) / 2;
    if (tab[akt] == x)
      return true;
    else if (tab[akt] > x)
      kon = akt - 1;
    else
      pocz = akt + 1;
  }
  return false;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  for (int i = 1; i * i <= C; i++) {
    tab[i] = i * i;
    sqr++;
  }
  cin >> n;
  int d = 0;
  while (n > 0) {
    dig[d] = n % 10;
    n /= 10;
    d++;
  }
  for (int i = 0; i < (1 << d); i++) {
    n = 0;
    int pot = 1, zer = 0;
    bool blep = false;
    for (int j = 0; j < d; j++) {
      if (((1 << j) & i) == 0) {
        zer++;
        n += dig[j] * pot;
        pot *= 10;
        if (dig[j] == 0)
          blep = false;
        else
          blep = true;
      }
    }
    if (!blep) continue;
    if (binsearch(n)) wyn = min(wyn, d - zer);
  }
  if (wyn == 11) wyn = -1;
  cout << wyn << endl;
  return 0;
}
