#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
const int INF = 1000000000;
int main() {
  ios::sync_with_stdio(false);
  string s;
  cin >> s;
  long long n = stoll(s);
  vector<long long> squares;
  squares.reserve(45000);
  for (long long i = 1; i * i <= n; i++) squares.push_back(i * i);
  int result = INF;
  int maxMask = 1 << s.length();
  for (int mask = 0; mask < maxMask; mask++) {
    vector<char> subseq;
    int cntRemoved = 0;
    subseq.reserve(s.length());
    for (int i = 0; i < s.length(); i++) {
      if ((mask & (1 << i)) > 0)
        subseq.push_back(s[i]);
      else
        cntRemoved++;
    }
    if (subseq.size() == 0 || subseq[0] == '0') continue;
    string numStr(subseq.begin(), subseq.end());
    long long num = stoll(numStr);
    auto it = lower_bound(squares.begin(), squares.end(), num);
    if (it != squares.end() && *it == num) result = min(result, cntRemoved);
  }
  cout << (result == INF ? -1 : result) << endl;
}
