#include <bits/stdc++.h>
using namespace std;
const int oo = (int)1e9;
const double PI = 2 * acos(0.0);
const double eps = 1e-7;
int dx[] = {1, 0, 0, -1, -1, -1, 1, 1};
int dy[] = {0, 1, -1, 1, 1, -1, 1, -1};
const int MOD = 1e9 + 7;
int calc(int r, int n) {
  int aa = r, bb = n;
  while (r > 0 && n > 0) {
    if (r % 10 == n % 10) r /= 10;
    n /= 10;
  }
  if (r == 0)
    return int(log10(bb)) + 1 - (int(log10(aa)) + 1);
  else
    return -1;
}
int main() {
  int n;
  cin >> n;
  int ans = 1000000000;
  int sqr = (int)sqrt(n);
  for (int i = 1; i < sqr + 1; i++) {
    int ret = calc(i * i, n);
    if (ret != -1) ans = min(ans, ret);
  }
  if (ans == 1000000000) ans = -1;
  cout << ans << endl;
}
