#include <bits/stdc++.h>
using namespace std;
const long long int mod = 1000000007;
long long int ans = -1;
long long int lens(long long int n) {
  long long int ans = 0;
  while (n) {
    ans++;
    n /= 10;
  }
  return ans;
}
long long int num_to_string(string second) {
  long long int num = -1;
  for (long long int i = 0; i < second.size(); i++)
    num == -1 ? num = second[i] - '0' : num = num * 10 + (second[i] - '0');
  return num;
}
void brute_rec(string second, long long int op) {
  long long int N = num_to_string(second);
  if (!N) return;
  long long int v = sqrt(N);
  long long int dd = second.size() - lens(N) + 1;
  if (v * v == N) {
    ans == -1 ? ans = op + (dd - 1) : ans = min(ans, op + (dd - 1));
    return;
  }
  set<string> pos;
  long long int n = second.size();
  for (long long int i = 0; i < n; i++) {
    string a = "";
    for (long long int j = 0; j < n; j++)
      if (i == j)
        continue;
      else
        a += second[j];
    pos.insert(a);
  }
  pos.erase("");
  for (auto it : pos) brute_rec(it, op + dd);
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
  string second;
  cin >> second;
  brute_rec(second, 0);
  cout << ans << endl;
  return 0;
}
