#include <bits/stdc++.h>
using namespace std;
void func(void);
signed int main(void) {
  func();
  ;
  return 0;
}
bool isKaibun(vector<int> &chk) {
  int oddCnt = 0;
  for (int i = 0; i < 26; i++) {
    if (chk[i] % 2 != 0) {
      oddCnt++;
    }
    if (oddCnt > 1) {
      break;
    }
  }
  if (oddCnt > 1) {
    return false;
  } else {
    return true;
  }
}
int searchKaibun(string &s) {
  vector<int> chkOrg(26, 0);
  int len = s.size();
  if (len == 0) {
    return 0;
  } else if (len == 1) {
    return 1;
  } else if (len == 2) {
    if (s[0] == s[1]) {
      return 1;
    } else {
      return 2;
    }
  }
  for (int k = 0; k < len; k++) {
    chkOrg[s[k] - 'a']++;
  }
  int i;
  int j;
  bool findKaibun = false;
  for (i = 0; (i < len && !findKaibun); i++) {
    vector<int> chk = chkOrg;
    for (int ii = 0; ii < i; ii++) {
      chk[s[ii] - 'a']--;
    }
    for (j = len - 1; j >= i; j--) {
      if (isKaibun(chk)) {
        findKaibun = true;
        i--;
        break;
      }
      chk[s[j] - 'a']--;
    }
  }
  int m;
  int n;
  bool findKaibun2 = false;
  for (m = len - 1; (m >= 0 && !findKaibun2); m--) {
    vector<int> chk = chkOrg;
    for (int ii = len - 1; ii > m; ii--) {
      chk[s[ii] - 'a']--;
    }
    for (n = 0; n <= m; n++) {
      if (isKaibun(chk)) {
        findKaibun2 = true;
        m++;
        break;
      }
      chk[s[n] - 'a']--;
    }
  }
  if (j - i < m - n) {
    i = n;
    j = m;
  }
  if (findKaibun) {
    string s1 = s.substr(0, i);
    string s2 = s.substr(j + 1, len - j - 1);
    ;
    int anss1 = searchKaibun(s1);
    int anss2 = searchKaibun(s2);
    return anss1 + anss2 + 1;
  } else {
    return -1;
  }
}
void func(void) {
  string s;
  cin >> s;
  cout << searchKaibun(s) << endl;
  return;
}
