#include <bits/stdc++.h>
using namespace std;
map<string, long long> mp;
void generate(string s) {
  int set_size = s.length();
  unsigned int pow_set_size = pow(2, set_size);
  int counter, j;
  for (counter = 0; counter < pow_set_size; counter++) {
    string ans = "";
    for (j = 0; j < set_size; j++) {
      if (counter & (1 << j)) ans += s[j];
    }
    if (ans[0] != 0) mp[ans] = 1;
  }
}
int main() {
  string n;
  cin >> n;
  generate(n);
  vector<string> v;
  for (int i = 1; i < 1e9; i++) {
    long long x = i * i;
    if (x > 2 * 1e9) break;
    v.push_back(to_string(x));
  }
  for (int i = v.size() - 1; i >= 0; i--) {
    if (mp[v[i]] == 1) {
      cout << n.length() - v[i].length();
      return 0;
    }
  }
  cout << -1 << endl;
}
