#include <bits/stdc++.h>
using namespace std;
const long long N = 1e6 + 5;
const long long INF = 1e9 + 7;
long long n, ans = INF;
string s;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  cin >> s;
  long long n = s.size();
  for (long long mask = 1; mask < 1 << n; mask++) {
    long long t = 0;
    bool check = true;
    for (long long i = 0; i < n; i++)
      if (mask >> i & 1) {
        t = t * 10 + s[i] - '0';
        if (t == 0 && s[i] == '0') check = false;
      }
    long long tt = sqrt(t);
    if (tt * tt == t && tt != 0 && check)
      ans = min(ans, n - __builtin_popcount(mask));
  }
  cout << (ans == INF ? -1 : ans);
  return 0;
}
