#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimization("unroll-loops")
std::pair<int, int> DR[] = {{-1, 0}, {0, 1},   {1, 0}, {0, -1},
                            {-1, 1}, {-1, -1}, {1, 1}, {1, -1}};
using namespace std;
template <class c>
struct rge {
  c b, e;
};
template <class c>
rge<c> range(c i, c j) {
  return rge<c>{i, j};
}
template <class c>
auto dud(c* x) -> decltype(cerr << *x, 0);
template <class c>
char dud(...);
struct debug {
  ~debug() { cerr << endl; }
  template <class c>
  typename enable_if<sizeof dud<c>(0) != 1, debug&>::type operator<<(c i) {
    cerr << boolalpha << i;
    return *this;
  }
  template <class c>
  typename enable_if<sizeof dud<c>(0) == 1, debug&>::type operator<<(c i) {
    return *this << range(begin(i), end(i));
  }
  template <class c, class b>
  debug& operator<<(pair<b, c> d) {
    return *this << "(" << d.first << ", " << d.second << ")";
  }
  template <class c>
  debug& operator<<(rge<c> d) {
    *this << "[";
    for (auto it = d.b; it != d.e; ++it) *this << ", " + 2 * (it == d.b) << *it;
    return *this << "]";
  }
};
int gcd(int a, int b) {
  if (b) return gcd(b, a % b);
  return a;
}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
map<int, int> m;
int ans = 1e9;
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cerr.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  for (int i = 1; i * i <= n; i++) {
    m[i * i] = 1;
  }
  string s = to_string(n);
  for (int mask = 1; mask < (1 << (int)((s).size())); mask++) {
    int first = -1;
    string str = "";
    for (int i = 0; i < (int)((s).size()); i++) {
      if (mask & (1 << i)) {
        if (first == -1) first = s[i] - '0';
        str += s[i];
      }
    }
    if (first != 0 && m[stoi(str)])
      ans = min(ans, (int)((s).size()) - __builtin_popcount(mask));
  }
  if (ans == 1e9) return cout << -1, 0;
  return cout << ans, 0;
  return 0;
}
