#include <bits/stdc++.h>
using namespace std;
string str;
int ans, l;
int dig(int num) {
  int d = 0;
  while (num > 0) {
    d++;
    num = num / 10;
  }
  return d;
}
bool sq(int num) {
  int s = sqrt(num);
  if (s * s == num) return 0;
  s--;
  if (s * s == num) return 0;
  s += 2;
  if (s * s == num) return 0;
  return 1;
}
void func(int p, int num) {
  if (p == l) {
    if (sq(num)) return;
    ans = min(ans, p - dig(num));
    return;
  }
  int d = str[p] - '0';
  func(p + 1, num);
  func(p + 1, num * 10 + d);
}
int main() {
  cin >> str;
  l = str.length();
  ans = l;
  func(0, 0);
  if (ans == l) ans = -1;
  cout << ans << endl;
}
