#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e9 + 10l;
int main() {
  vector<int> vec;
  for (int i = 1; i * i < maxn; i++) {
    vec.push_back(i * i);
  }
  string s;
  cin >> s;
  int ans = maxn;
  for (auto x : vec) {
    int tmp = x;
    vector<int> t;
    while (tmp) {
      t.push_back(tmp % 10);
      tmp /= 10;
    }
    reverse(t.begin(), t.end());
    int j = 0;
    for (int i = 0; i < s.size(); i++) {
      if (j < t.size() && t[j] == s[i] - '0') j++;
    }
    if (j == t.size()) ans = min(ans, (int)s.size() - (int)(t.size()));
  }
  if (ans == maxn) {
    cout << -1 << endl;
    return 0;
  }
  cout << ans << endl;
}
