#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
template <typename T, typename TT>
ostream &operator<<(ostream &os, const pair<T, TT> &t) {
  return os << t.first << " " << t.second;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &t) {
  for (auto &i : t) os << i << " ";
  return os;
}
template <typename T>
istream &operator>>(istream &is, vector<T> &v) {
  for (T &t : v) is >> t;
  return is;
}
template <typename T1, typename T2>
istream &operator>>(istream &is, vector<pair<T1, T2>> &v) {
  for (pair<T1, T2> &t : v) is >> t.first >> t.second;
  return is;
}
const long long mod = 1e9 + 7;
void solve() {
  vector<string> sq;
  for (long long i = 1; i * i < 2e9 + 4; i++) {
    long long num = i * i;
    string cur = "";
    while (num) {
      int rem = num % 10;
      cur += char('0' + rem);
      num /= 10;
    }
    reverse(cur.begin(), cur.end());
    sq.push_back(cur);
  }
  string s;
  cin >> s;
  long long ans = 1e18;
  for (auto &x : sq) {
    if (x.size() > s.size()) break;
    long long i = 0, j = 0;
    while (i < s.size() and j < x.size()) {
      if (s[i] == x[j]) j++;
      i++;
    }
    if (j == x.size()) ans = min(ans, (long long)(s.size() - x.size()));
  }
  if (ans == 1e18)
    cout << -1 << '\n';
  else
    cout << ans << '\n';
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  long long t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
