#include <bits/stdc++.h>
using namespace std;
const int N = 5e5 + 7, inf = 1e9 + 7;
string s;
int ans = inf;
bool ok = 0;
void rec(int n, long long cnt = 0, int u = 0) {
  if (n == s.size()) {
    if (u == 0) {
      return;
    }
    if ((long long)sqrt(cnt) * (long long)sqrt(cnt) == (long long)cnt) {
      ans = min(ans, (int)s.size() - u);
      ok = 1;
    }
    return;
  }
  if (cnt == 0 && s[n] == '0') {
    rec(n + 1, cnt, u);
    return;
  }
  rec(n + 1, (cnt * 10) + (int)(s[n] - '0'), u + 1);
  rec(n + 1, cnt, u);
}
int main() {
  cin >> s;
  rec(0);
  if (ok == 0) {
    cout << -1 << endl;
    exit(0);
  }
  cout << ans << endl;
  exit(0);
}
