#include <bits/stdc++.h>
using namespace std;
int newahoise;
bool globalflag = false;
int mn = 200000000;
void backing(int from, int sum, int nisi, int sz, int a[]) {
  if (from == sz) {
    return;
  }
  for (int i = from + 1; i < sz; i++) {
    int oho = (sum * 10) + a[i];
    int f = sqrt(oho);
    if ((pow(f, 2)) == oho) {
      mn = min(mn, sz - (nisi + 1));
      globalflag = true;
    }
    backing(i, oho, nisi + 1, sz, a);
  }
}
int main() {
  string n;
  cin >> n;
  int a[n.size()];
  int len = n.size();
  for (int i = 0; i < len; i++) {
    a[i] = n[i] - '0';
  }
  bool flag = false;
  for (int i = 0, ehem = len; i < len; i++, ehem--) {
    if (a[i] > 0) {
      int h = sqrt(a[i]);
      if (pow(h, 2) == a[i]) {
        mn = min(mn, len - 1);
        flag = true;
      }
      backing(i, a[i], 1, len, a);
      if (globalflag) {
        flag = true;
      }
    }
  }
  if (flag) {
    cout << mn << endl;
  } else
    cout << "-1" << endl;
}
