#include <bits/stdc++.h>
using namespace std;
int power(int a, int b) {
  if (b == 0)
    return 1;
  else {
    int f = a;
    for (int i = 0; i < b - 1; i++) a *= f;
    return a;
  }
}
int main() {
  string a;
  cin >> a;
  int d = a.size();
  int max = 0;
  for (int i = 0; i < (1 << d); i++) {
    int f = 0, l = 0;
    vector<int> vi;
    for (int j = 0; j < d; j++) {
      if (i & (1 << j)) {
        vi.push_back(1);
        f++;
      } else
        vi.push_back(0);
    }
    int u = f;
    f--;
    for (int j = 0; j < vi.size(); j++) {
      if (vi[j] == 1) {
        l += power(10, f) * (a[j] - '0');
        f--;
      }
    }
    int y = l, r = 0;
    while (y > 0) {
      y /= 10;
      r++;
    }
    int k = sqrt(l);
    if (k * k == l && r == u) {
      if (max < u) max = u;
    }
  }
  if (max == 0)
    cout << -1;
  else
    cout << d - max;
  return 0;
}
