#include <bits/stdc++.h>
using namespace std;
template <typename T>
void MACRO_VAR_Scan(T& t) {
  cin >> t;
}
template <typename First, typename... Rest>
void MACRO_VAR_Scan(First& first, Rest&... rest) {
  cin >> first;
  MACRO_VAR_Scan(rest...);
}
template <typename T>
void MACRO_VEC_ROW_Init(int n, T& t) {
  t.resize(n);
}
template <typename First, typename... Rest>
void MACRO_VEC_ROW_Init(int n, First& first, Rest&... rest) {
  first.resize(n);
  MACRO_VEC_ROW_Init(n, rest...);
}
template <typename T>
void MACRO_VEC_ROW_Scan(int p, T& t) {
  cin >> t[p];
}
template <typename First, typename... Rest>
void MACRO_VEC_ROW_Scan(int p, First& first, Rest&... rest) {
  cin >> first[p];
  MACRO_VEC_ROW_Scan(p, rest...);
}
void _main();
signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  _main();
}
inline long long toInt(std::string s) {
  long long v;
  std::istringstream sin(s);
  sin >> v;
  return v;
}
template <class T>
inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}
template <class T>
inline T sqr(T x) {
  return x * x;
}
template <typename A, typename B>
inline void chmin(A& a, B b) {
  if (a > b) a = b;
}
template <typename A, typename B>
inline void chmax(A& a, B b) {
  if (a < b) a = b;
}
long long qp(long long a, long long b) {
  long long ans = 1ll;
  do {
    if (b & 1) ans = 1ll * ans * a;
    a = 1ll * a * a;
  } while (b >>= 1);
  return ans;
}
long long qpmod(long long a, long long b, long long mo) {
  long long ans = 1ll;
  do {
    if (b & 1) ans = 1ll * ans * a % mo;
    a = 1ll * a * a % mo;
  } while (b >>= 1);
  return ans;
}
inline long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
inline long long lcm(long long a, long long b) { return a / gcd(a, b) * b; }
inline bool valid(int x, int h) { return 0 <= x && x < h; }
const double EPS = 1e-8;
const double PI = acos(-1.0);
const int INF = (int)(1e9) + 7;
const long long MOD = (long long)(1e9) + 7;
const long long MOD2 = (long long)(1e18) + 9;
const long long INF2 = (long long)(1e18);
const long long INTMAX = (0x7FFFFFFFL);
const long long LLMAX = (0x7FFFFFFFFFFFFFFFL);
const int N4 = (int)1e4 + 10;
const int N5 = (int)1e5 + 10;
const int N9 = (int)1e9;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, -1, -1, 1, 1};
struct uf_tree {
  std::vector<int> parent;
  int __size;
  uf_tree(int size_) : parent(size_, -1), __size(size_) {}
  void unite(int x, int y) {
    if ((x = find(x)) != (y = find(y))) {
      if (parent[y] < parent[x]) std::swap(x, y);
      parent[x] += parent[y];
      parent[y] = x;
      __size--;
    }
  }
  bool is_same(int x, int y) { return find(x) == find(y); }
  int find(int x) { return parent[x] < 0 ? x : parent[x] = find(parent[x]); }
  int size(int x) { return -parent[find(x)]; }
  int size() { return __size; }
};
long long digitsum(long long x) {
  long long dig;
  long long summ = 0;
  while (x) {
    dig = x % 10;
    summ = summ + dig;
    x = x / 10;
  }
  return summ;
}
string S;
bool C(string s) {
  if (int((s).size()) == 0) {
    return false;
  }
  if (s[0] == '0') {
    return false;
  }
  int x = toInt(s);
  int sq = sqrt(x);
  return (sq > 0 && sq * sq == x);
}
long long ret, cnt, cur, sum, ans, f;
void _main() {
  cin >> S;
  int n = int((S).size());
  ret = -1;
  for (int bit = (0); bit < (1 << n); ++bit) {
    string s = "";
    for (int i = (0); i < (n); ++i) {
      if (bit & (1 << i)) {
        s += S[i];
      }
    }
    if (C(s)) chmax(ret, int((s).size()));
  }
  cout << (ret == -1 ? -1 : n - ret) << endl;
}
