#include <bits/stdc++.h>
using namespace std;
void solve() {
  string str;
  cin >> str;
  long long n = str.length();
  long long ans = INT_MAX;
  for (long long mask = 0; mask < (1 << n); mask++) {
    string curr;
    for (long long i = 0; i < n; i++) {
      if (mask & (1 << i)) curr += str[i];
    }
    if (!curr.empty() and curr[0] != '0') {
      long long x = stoi(curr);
      long long val = sqrt(x);
      if (val * val == x) {
        ans = min(ans, (long long)n - (long long)curr.size());
      }
    }
  }
  if (ans != INT_MAX)
    cout << ans << endl;
  else
    cout << -1 << endl;
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  solve();
}
