#include <bits/stdc++.h>
using namespace std;
bool isprime[2000005];
void setprime() {
  for (long long i = 0; i < 2000005; i++) isprime[i] = true;
  isprime[0] = false;
  isprime[1] = false;
  for (long long i = 2; i < 2000005; i++) {
    for (long long j = 2; i * j < 2000005; j++) isprime[i * j] = false;
  }
}
long long choose(long long n, long long k) {
  if (k == 0) return 1;
  return (n * choose(n - 1, k - 1)) / k;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long n;
  cin >> n;
  long long temp = n;
  vector<long long> v;
  while (temp > 0) {
    v.push_back(temp % 10);
    temp /= 10;
  }
  reverse(v.begin(), v.end());
  long long size = 1 << v.size();
  vector<long long> v1[size];
  for (long long i = 0; i < size; i++) {
    for (long long j = 0; j < v.size(); j++) {
      if (1 << j & i) {
        v1[i].push_back(v[j]);
      }
    }
  }
  long long ans = -1;
  for (long long i = 1; i < size; i++) {
    long long a = 0;
    long long b = 1;
    for (long long j = v1[i].size() - 1; j >= 0; j--) {
      a += (v1[i][j]) * b;
      b *= 10;
    }
    if (a != 0) {
      double temp2 = sqrt(a);
      if (ceil(temp2) == floor(temp2)) {
        long long c = a;
        long long count1 = 0;
        while (c > 0) {
          c /= 10;
          count1++;
        }
        ans = max(ans, count1);
      }
    }
  }
  if (ans == -1) {
    cout << ans;
  } else {
    cout << v.size() - ans;
  }
}
