#include <iostream>
#include <algorithm>
using namespace std;
int main(void){
  string s;
  cin >> s;
  int l = 0;
  int r = s.size()-1;
  int 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;
}