#include <bits/stdc++.h>
using namespace std;
string s;
set<int> sq;
bool isValid(int msk) {
  int num = 0;
  for (int i = 0; i < 10; ++i) {
    if ((1 << i) & msk) {
      if (num == 0 && s[i] == '0') return false;
      num *= 10;
      num += (s[i] - '0');
    }
  }
  if (sq.count(num)) return true;
  return false;
}
int main() {
  cin >> s;
  for (int i = 1; i <= 44722; ++i) {
    sq.insert(i * i);
  }
  int n = s.size();
  int ans = -1;
  for (int i = 0; i < (1 << n); ++i) {
    if (isValid(i)) {
      if (ans == -1 || __builtin_popcount(ans) < __builtin_popcount(i)) ans = i;
    }
  }
  if (ans == -1)
    cout << -1 << endl;
  else
    cout << n - __builtin_popcount(ans) << endl;
  return 0;
}
