#include <bits/stdc++.h>
using namespace std;
const double eps = 1e-5;
const long long INF = (long long)(1e9) * (long long)(1e9);
template <class T>
void chmin(T& a, const T& b) {
  if (a > b) a = b;
}
template <class T>
void chmax(T& a, const T& b) {
  if (a < b) a = b;
}
const long long pow(const long long p, const long long q) {
  long long t = 1;
  for (int i = (0); i < (int)(q); ++i) t *= p;
  return t;
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  string ss;
  cin >> ss;
  string s = "";
  for (int i = (0); i < (int)(ss.size()); ++i) {
    if (ss[i] == 'x') continue;
    s += string{ss[i]};
  }
  for (int i = (0); i < (int)(s.size() / 2); ++i) {
    if (s[i] != s[s.size() - i - 1]) {
      cout << -1 << endl;
      return 0;
    }
  }
  int ans = 0;
  int l = 0, r = ss.size() - 1;
  for (int i = (0); i < (int)((s.size() + 1) / 2); ++i) {
    if (l >= r) break;
    while (ss[l] == 'x' && ss[r] == 'x') {
      l++;
      r--;
      if (l >= r) break;
    }
    while (ss[l] != s[i]) {
      l++;
      ans++;
    }
    while (ss[r] != s[i]) {
      r--;
      ans++;
    }
    l++;
    r--;
  }
  cout << ans << endl;
}
