#include <bits/stdc++.h>
using namespace std;
const int N = (int)(1 * 1e6 + 10);
int bit[N];
void update(int i, int add) {
  while (i > 0 && i < N) {
    bit[i] += add;
    i += (i & (-i));
  }
}
int sum1(int i) {
  int s = 0;
  while (i > 0) {
    s += bit[i];
    i = i - (i & (-i));
  }
  return s;
}
std::map<long long, long long> has;
set<long long> s1;
bool check(string r) {
  long long val = stoi(r);
  if (s1.find(val) != s1.end()) {
    return true;
  }
  return false;
}
long long maskseq(string s) {
  long long power = pow(2, (long long)s.size());
  long long maxi = -1;
  for (long long i = 1; i < power; i++) {
    string r = "";
    for (long long j = 0; j < s.size(); j++) {
      if (i & (1 << j)) {
        r += s[j];
      }
    }
    if (r[0] != '0') {
      if (check(r)) {
        maxi = max(maxi, (long long)r.size());
      }
    }
  }
  return maxi;
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long n, a, b;
  long long h, m, H, D, C;
  std::vector<long long> v1;
  std::vector<long long> v2;
  string s;
  cin >> s;
  for (long long i = 1; i * i <= 2 * 1000000000; i++) {
    s1.insert(i * i);
  }
  if (maskseq(s) == -1) return cout << -1, 0;
  cout << (long long)s.size() - maskseq(s);
  return 0;
}
