#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
const long long mod = 1e9 + 7;
const long long Max = 2e9 + 5;
long long sq[N];
int c = 0;
void init() {
  for (int i = 0; i < N; ++i) {
    long long res = i * i;
    if (res > Max) break;
    sq[c++] = res;
  }
}
long long pow(int x, int n) {
  long long res = 1;
  for (int i = 1; i < n + 1; ++i) {
    res = res * x;
  }
  return res;
}
bool check(long long x) {
  if (binary_search(sq, sq + c, x)) return true;
  return false;
}
int main() {
  long long n;
  string s;
  cin >> s;
  init();
  int len = s.length();
  long long x;
  int ans = 99999;
  for (int i = 0; i < 1 << len; ++i) {
    x = 0;
    int num = 0;
    vector<int> res;
    for (int j = 0; j < len; ++j) {
      if ((i >> j) & 1) {
        res.push_back(s[len - 1 - j] - '0');
        num++;
      }
    }
    x = 0;
    if (res.size() == 0) continue;
    int d = res.size();
    if (res[d - 1] == 0) continue;
    for (int i = res.size() - 1; i >= 0; --i) {
      x = x * 10 + res[i];
    }
    if (check(x)) {
      ans = min(ans, len - num);
    }
  }
  if (ans == 99999)
    cout << -1 << endl;
  else
    cout << ans << endl;
  return 0;
}
