#include <bits/stdc++.h>
using namespace std;
int main() {
  int tc;
  tc = 1;
  while (tc--) {
    string str;
    cin >> str;
    int l = str.size();
    int ans = 20;
    for (long long i = 1; i <= 100000; i++) {
      long long temp = i * i;
      string strr = to_string(temp);
      int lr = strr.size();
      int ii = 0, j = 0;
      if (lr > l) break;
      while (ii < l and j < lr) {
        if (str[ii] == strr[j]) j++;
        ii++;
      }
      if (j == lr) {
        ans = min(ans, l - lr);
      }
    }
    if (ans == 20)
      cout << -1 << "\n";
    else
      cout << ans << "\n";
  }
  return 0;
}
