#include <bits/stdc++.h>
using namespace std;
const int N = 100;
void get_mask(int mx, int &ans, int len, string &str) {
  string s;
  int len1 = 0;
  for (int i = 0; i < len; ++i) {
    if (mx & (1 << i)) {
      s += str[i];
      ++len1;
    }
  }
  if (s[0] == '0' || len - len1 >= ans) return;
  int x = 0, y;
  for (auto &v : s) x = x * 10 + v - '0';
  y = sqrt(x);
  if (y * y == x) {
    ans = min(ans, len - len1);
  }
  return;
}
int solve(string &str) {
  int len = str.length();
  int ans = 1e9;
  for (int i = 1; i < (1 << len); ++i) {
    get_mask(i, ans, len, str);
  }
  return ans == 1e9 ? -1 : ans;
}
int main() {
  ios::sync_with_stdio(false);
  string str;
  while (cin >> str) {
    int ans = solve(str);
    cout << ans << '\n';
  }
  return 0;
}
