#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
const ll mod = 1e9 + 7;
const ll INF = 1e9;
int main() {
  cin.sync_with_stdio(false);
  string s;
  cin >> s;
  string t1, t2;
  bool flag1 = true;
  for (int i = 0; i < (int)(s.size()); i++) {
    if (s[i] != s[s.size() - 1 - i]) {
      flag1 = false;
    }
  }
  if (flag1) {
    cout << 0 << endl;
    return 0;
  }
  for (int i = 0; i < (int)(s.size()); i++) {
    if (s[i] != 'x') t1.push_back(s[i]);
  }
  for (int i = 0; i < (int)(t1.size()); i++)
    t2.push_back(t1[t1.size() - 1 - i]);
  for (int i = 0; i < (int)(t1.size()); i++) {
    if (t1[i] != t2[i]) {
      cout << -1 << endl;
      return 0;
    }
  }
  int leng = t1.size();
  int k;
  if (leng % 2 == 0)
    k = leng / 2 - 1;
  else
    k = leng / 2;
  int cnt = 0;
  set<int> st;
  int ans = 0;
  for (int i = 0; i < (int)(s.size()); i++) {
    if (s[i] == 'x') {
      st.insert(i);
      ans++;
    } else if (cnt == k) {
      break;
    } else
      cnt++;
  }
  cnt = 0;
  bool flag = false;
  for (int i = 0; i < (int)(s.size()); i++) {
    if (i == 0 && s[s.size() - 1 - i] != s[i]) {
      flag = true;
    }
    if (s[s.size() - 1 - i] == 'x') {
      if (flag) {
        if (st.count(i + 1))
          ans--;
        else
          ans++;
      } else if (st.count(i))
        ans--;
      else
        ans++;
    } else if (cnt == k)
      break;
    else
      cnt++;
  }
  cout << ans << endl;
  return 0;
}
