#include <bits/stdc++.h>
using namespace std;
unsigned long long fact(unsigned long long n, unsigned long long i) {
  unsigned long long ans = 1;
  if (n == 0 || n == 1) return ans;
  while (n != i) {
    ans = ans * n;
    n--;
  }
  cout << ans << endl;
  return ans;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  unsigned long long n;
  cin >> n;
  unsigned long long x = sqrt(n);
  string s = to_string(n);
  unsigned long long z = s.size();
  while (x >= 1) {
    unsigned long long y = x * x;
    string ans = to_string(y);
    unsigned long long sz = ans.size();
    unsigned long long i = 0, j = 0;
    while (j < z) {
      if (ans[i] == s[j]) {
        i++;
        j++;
      } else
        j++;
    }
    if (i == sz) {
      cout << z - sz;
      return 0;
    }
    x--;
  }
  cout << "-1";
}
