#include <bits/stdc++.h>
#pragma GCC optimize(114514)
using namespace std;
const long long maxnode = 450010;
const long long maxn = 1000010;
const long long maxm = 100010;
const long long mod = 998244353;
const double pi = acos(-1.0);
const double eps = 1e-8;
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
long long lcm(long long a, long long b) { return a / gcd(a, b) * b; }
long long qpow(long long a, long long b) {
  long long sum = 1;
  while (b) {
    if (b & 1) {
      sum = (sum * a);
      b--;
    }
    b /= 2;
    a = a * a;
  }
  return sum;
}
long long powmod(long long a, long long b, long long mod) {
  long long sum = 1;
  while (b) {
    if (b & 1) {
      sum = (sum * a) % mod;
      b--;
    }
    b /= 2;
    a = a * a % mod;
  }
  return sum;
}
int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b); }
inline int read() {
  int x = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = 10 * x + ch - '0';
    ch = getchar();
  }
  return x * f;
}
inline long long readll() {
  long long x = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = 10 * x + ch - '0';
    ch = getchar();
  }
  return x * f;
}
inline void write(int x) {
  if (x < 0) x = ~x + 1, putchar('-');
  if (x > 9) write(x / 10);
  putchar(x % 10 + '0');
}
int n, a, b, k, m, p;
string str1, str2;
int maxx = -1;
void dd(int ind, int now, int cot) {
  m = floor(sqrt(now) + 0.5);
  if (m * m == now && now) maxx = max(maxx, cot);
  if (ind == str1.size()) return;
  if (str1[ind] == '0') {
    if (!cot) {
      dd(ind + 1, now, cot);
    } else {
      dd(ind + 1, now * 10, cot + 1);
      dd(ind + 1, now, cot);
    }
  } else {
    dd(ind + 1, now * 10 + (str1[ind] - '0'), cot + 1);
    dd(ind + 1, now, cot);
  }
}
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  int T;
  cin >> str1;
  dd(0, 0, 0);
  if (maxx == -1)
    cout << -1 << endl;
  else
    cout << str1.size() - maxx << endl;
  return 0;
}
