#include <bits/stdc++.h>
using namespace std;
bool full_square(int a) {
  int i;
  for (i = 1; i * i < a; i++) continue;
  if (i * i == a) return 1;
  return 0;
}
int length(int &a) {
  int cnt = 0;
  while (a > 0) {
    a /= 10;
    cnt++;
  }
  return cnt;
}
int main() {
  char c;
  vector<int> n;
  while (cin >> c) {
    n.push_back(c - '0');
  }
  int m = -1;
  int num;
  for (int i = 0; i < (1 << n.size()); i++) {
    num = 0;
    int k = i;
    for (int j = 0; j < n.size(); j++) {
      if (k & 1) num = num * 10 + n[j];
      k >>= 1;
    }
    if (num > 0 && full_square(num)) m = max(num, m);
  }
  if (m > 0)
    cout << n.size() - length(m);
  else
    cout << -1;
  cin.get();
  cin.get();
}
