#include <bits/stdc++.h>
using namespace std;
template <typename T>
void read(T &x) {
  register T c = getchar();
  x = 0;
  int t = 0;
  if (c == '-') t = 1, c = getchar();
  for (; (c < 48 || c > 57); c = getchar())
    ;
  for (; c > 47 && c < 58; c = getchar()) {
    x = (x << 1) + (x << 3) + c - 48;
  }
  if (t) x = -x;
}
int main() {
  string s;
  cin >> s;
  long long l = s.length();
  long long tot = pow(2, l);
  long long ans = LLONG_MAX;
  bool found = false;
  for (int i = 1; i < tot; ++i) {
    long long temp = 1 << (l - 1);
    long long num = 0;
    long long cnt = l;
    bool f = true;
    bool prev = false;
    for (int j = 0; j < l; ++j) {
      if (temp & i) {
        num = num * 10 + (s[j] - '0');
        --cnt;
        if (f) {
          if (s[j] == '0') {
            prev = true;
          }
          f = false;
        }
      }
      temp >>= 1;
    }
    if (prev) continue;
    long long sq = sqrt(num);
    if ((sq * sq) == num) {
      ans = min(ans, cnt);
      found = true;
    }
  }
  if (found)
    cout << ans;
  else
    cout << -1;
}
