#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> a;
  while (n > 0) {
    a.push_back(n % 10);
    n /= 10;
  }
  auto valid = [](int x) {
    int t = (int)sqrt(x);
    return t * t == x;
  };
  int ans = -1, sz = (int)a.size();
  for (int mask = 0; mask < (1 << sz); ++mask) {
    int t = 0, last = -1;
    for (int i = 0, p = 1; i < sz; ++i) {
      if ((mask >> i) & 1) {
        t += a[i] * p;
        p *= 10;
        last = a[i];
      }
    }
    if (t == 0 || last == 0) {
      continue;
    }
    if (valid(t)) {
      int del = sz - __builtin_popcount(mask);
      ans = ans == -1 ? del : min(ans, del);
    }
  }
  cout << ans;
}
