#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int c = floor(log10(n)) + 1;
  vector<int> dig;
  int t = n;
  while (t > 0) {
    dig.push_back(t % 10);
    t /= 10;
  }
  int ans = INT_MAX;
  for (int mask = 0; mask < 1 << c; mask++) {
    int num = 0;
    int pw = 1;
    int last = 0;
    for (int i = 0; i < c; i++) {
      if (mask & (1 << i)) {
        num += dig[i] * pw;
        pw *= 10;
        last = dig[i];
      }
    }
    if (last != 0 && floor(sqrt(num)) * floor(sqrt(num)) == num) {
      ans = min(ans, c - __builtin_popcount(mask));
    }
  }
  cout << (ans == INT_MAX ? -1 : ans) << endl;
}
