#include <bits/stdc++.h>
using namespace std;
int k, cr[100000], ar[200010];
void subsets(int *arr, int index, int l) {
  static vector<int> ans;
  if (index == l) {
    int m = 0;
    for (int i = 0; i < ans.size(); i++) {
      m = m * 10 + ans[i];
    }
    if (ans.size() > 0) {
      ar[k] = m;
      k++;
    }
    return;
  }
  subsets(arr, index + 1, l);
  ans.push_back(arr[index]);
  subsets(arr, index + 1, l);
  ans.pop_back();
}
int main() {
  string str;
  while (cin >> str) {
    int i, j, l, m, n, p1;
    l = str.length();
    k = 0;
    for (i = 0; i < l; i++) {
      cr[i] = (str[i] - 48);
    }
    subsets(cr, 0, l);
    p1 = k;
    sort(ar, ar + p1);
    long long s, br[200010], k1;
    map<int, int> mp;
    for (i = 0;; i++) {
      s = i * i;
      if (s <= 2000000000) {
        k1 = i * i;
        mp[k1] = 1;
      } else
        break;
    }
    k1 = 0;
    int l12;
    for (i = p1 - 1; i >= 0; i--) {
      if (mp[ar[i]] == 1) {
        k1 = 1;
        l12 = ar[i];
        break;
      }
    }
    if (k1 == 0 || l12 == 0)
      cout << -1 << endl;
    else {
      p1 = 0;
      if (l12 == 0) p1++;
      while (l12 != 0) {
        p1++;
        l12 = l12 / 10;
      }
      cout << l - p1 << endl;
    }
  }
  return 0;
}
