#include <bits/stdc++.h>
using namespace std;
const long long int INF = 0x3f3f3f3f3f3f3f3f;
const int inf = 0x3f3f3f3f;
const int MOD = 1e9 + 7;
const int MAX = 1e5 + 5;
int n, x, y;
map<int, bool> psq;
int main(int argc, char const *argv[]) {
  ios_base::sync_with_stdio(false);
  for (int i = 1; i <= 44722; i++) psq[i * i] = true;
  cin >> n;
  string s = to_string(n);
  int len = s.size();
  int ans = len;
  for (int i = 0; i < (1 << len); i++) {
    string t = "";
    for (int j = 0; j < len; j++) {
      if (i & (1 << j)) t = t + s[j];
    }
    if (t[0] == '0' || t == "")
      continue;
    else {
      int z = stoi(t);
      if (psq[z]) {
        ans = min(ans, len - (int)t.size());
      }
    }
  }
  cout << (ans == len ? -1 : ans);
  return 0;
}
