#include <bits/stdc++.h>
using namespace std;
long long power(long long a, long long n, long long mod) {
  long long p = 1;
  while (n > 0) {
    if (n & 1) {
      p = p * a;
      p %= mod;
    }
    n >>= 1;
    a *= a;
    a %= mod;
  }
  return p % mod;
}
set<long long> ss;
void pre() {
  for (long long i = 1; i < 100000; i++) {
    ss.insert(i * i);
  }
}
int main() {
  string s;
  cin >> s;
  pre();
  long long n = s.size();
  long long ma = -1;
  for (long long i = 0; i < ((long long)1 << n); i++) {
    long long num = 0, cnt = 0, f = 0;
    for (long long j = 0; j < n; j++) {
      if ((i & ((long long)1 << j)) > 0) {
        if ((s[j] - '0') > 0) f = 1;
        if (f > 0) cnt++;
        num = num * 10 + (s[j] - '0');
      }
    }
    if (ss.find(num) != ss.end()) {
      ma = max(ma, cnt);
    }
  }
  if (ma == -1)
    printf("-1\n");
  else
    printf("%lld\n", n - ma);
}
