#include "bits/stdc++.h"
using namespace std;

int solve(string &s) {
  deque<char> deq;
  for(auto i: s) deq.push_back(i);
  int ans = 0;
  while(deq.size() > 1) {
    if(deq.front() == deq.back()) deq.pop_front(), deq.pop_back();
    else if(deq.front() == 'x') deq.pop_front(), ++ans;
    else if(deq.back() == 'x') deq.pop_back(), ++ans;
    else return -1;
  }
  return ans;
}

int main() {
  string s;
  cin >> s;
  cout << solve(s) << '\n';
  return 0;
}
