#include <bits/stdc++.h>
using ll = long long;
using namespace std;
const ll mod = 1e9 + 7;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  string s;
  cin >> s;
  int n = (int)(s.size());
  int mx = -1;
  for (int i = 1; i < (1 << n); i++) {
    string tmp = "";
    int c = 0;
    for (int j = 0; j < 32; j++) {
      if ((i >> j) & 1) tmp += s[j], c++;
    }
    int num = stoi(tmp);
    double a = sqrt(num);
    if (a == (int)(a) && tmp[0] != '0') mx = max(mx, c);
  }
  if (mx != -1) mx = n - mx;
  cout << mx;
  return 0;
}
