#include <bits/stdc++.h>
using namespace std;
int top = 0, a[100000];
int judge(int tt) {
  int i, j, k;
  int tmp = tt;
  int snum2 = 0;
  int h[10];
  while (tmp) {
    snum2++;
    h[snum2] = tmp % 10;
    tmp /= 10;
  }
  for (i = top; i >= 1; i--) {
    int snum1 = 0;
    int g[10];
    tmp = a[i];
    while (tmp) {
      snum1++;
      g[snum1] = tmp % 10;
      tmp /= 10;
    }
    int ttt = 1;
    int flag = 0;
    for (int ii = 1; ii <= snum1; ii++) {
      if (flag) break;
      for (j = ttt; j <= snum2 + 1; j++) {
        if (j > snum2) {
          flag = 1;
          break;
        };
        if (h[j] == g[ii]) {
          ttt = j + 1;
          break;
        }
      }
    }
    if (!flag) return snum2 - snum1;
  }
  return -1;
}
int main() {
  for (int i = 1; i * i <= 2000000000; i++) {
    top++;
    a[top] = i * i;
  }
  int n;
  scanf("%d", &n);
  cout << judge(n) << endl;
}
