#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  long long num, ans = LLONG_MAX;
  cin >> num;
  string n = to_string(num);
  long long len = n.size();
  unordered_set<long long> second;
  for (long long i = 1; i < 1 << len; i++) {
    long long tnum = 0, j = len - 1, m = 1, cnt = 0, ti = i;
    while (ti != 0) {
      if (ti & 1) {
        tnum = tnum + (n[j] - 48) * m;
        cnt++;
        m *= 10;
      }
      j--;
      ti >>= 1;
    }
    long long sq = sqrt(tnum);
    if (sq * sq == tnum && !second.count(tnum) && tnum != 0) {
      ans = min(ans, len - cnt);
      second.insert(tnum);
    }
  }
  if (ans != LLONG_MAX)
    cout << ans;
  else
    cout << -1;
}
