#include <bits/stdc++.h>
using namespace std;
template <typename T>
using V = vector<T>;
int main() {
  string S;
  cin >> S;
  int l = 0, r = S.size() - 1, ans = 0;
  while (l < r) {
    if (S[l] == S[r])
      ++l, --r;
    else if (S[l] == 'x')
      ++ans, ++l;
    else if (S[r] == 'x')
      ++ans, --r;
    else {
      cout << -1 << endl;
      return 0;
    }
  }
  cout << ans << endl;
}
