#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n;
  scanf("%lld", &n);
  long long m = n;
  string s = "";
  while (m) {
    s = char(48 + (m % 10)) + s;
    m /= 10;
  }
  long long l = s.length();
  vector<long long> v;
  for (int i = 1; i <= 45000; i++) {
    if ((i * i) > n) break;
    v.push_back(i * i);
  }
  long long x = v.size();
  long long ans = -1;
  for (int i = 0; i < x; i++) {
    long long num = v[i];
    if (num > n) break;
    long long c = l - 1;
    while (num) {
      int fl = 0;
      int r = num % 10;
      for (int j = c; j >= 0; j--) {
        if ((s[j] - '0') == r) {
          c = j - 1;
          fl = 1;
          break;
        }
      }
      if (fl == 0) break;
      num /= 10;
    }
    if (num == 0) {
      long long dup = v[i];
      int cc = 0;
      while (dup) {
        dup /= 10;
        cc++;
      }
      ans = cc > ans ? cc : ans;
    }
  }
  if (ans != -1)
    cout << l - ans;
  else
    cout << -1;
  return 0;
}
