#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9 + 7;
const long long LINF = 1e18;
using namespace std;
void CINT() {}
template <class Head, class... Tail>
void CINT(Head&& head, Tail&&... tail) {
  cin >> head;
  CINT(move(tail)...);
}
template <class T = long long>
T IN() {
  T x;
  cin >> x;
  return (x);
}
template <class Head>
void VT(Head head) {}
template <class Head, class Seco, class... Tail>
void VT(Head&& head, Seco&& seco, Tail&&... tail) {
  seco.resize(head);
  VT(head, move(tail)...);
}
void VT2() {}
template <class Head, class... Tail>
void VT2(Head&& head, Tail&&... tail) {
  for (auto& youso_ : (head)) cin >> youso_;
  VT2(move(tail)...);
}
template <class Head>
void VT3(Head&& head) {}
template <class Head, class Seco, class... Tail>
void VT3(Head&& head, Seco&& seco, Tail&&... tail) {
  seco[head] = IN();
  VT3(head, move(tail)...);
}
int main() {
  string inp;
  CINT(inp);
  string s = "aaaaaaaaaa";
  for (int i = 0; i < (inp.size()); ++i) s[10 - inp.size() + i] = inp[i];
  set<long long> set_;
  for (int i = (1); i < (100000); ++i) set_.insert(1LL * i * i);
  long long cou = LINF;
  for (int i = 0; i < ((1 << inp.size()) - 1); ++i) {
    string t = s;
    long long count = 0;
    for (int j = 0; j < (inp.size()); ++j)
      if (i & 1 << j) {
        t.erase(t.begin() + (10 - inp.size() + j - count));
        count++;
      }
    while (t[0] == 'a') {
      t.erase(t.begin());
    }
    if (t[0] == '0') continue;
    long long num = stoll(t);
    if (set_.count(num)) {
      cou = min(cou, count);
    }
  }
  cout << ((cou == LINF ? -1 : cou)) << endl;
  return 0;
}
