#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin >> s;
  int n = s.length();
  int i,j;
  i=0;
  j=n-1;
  int ans = 0;
  while(i<j){
    if(s[i]==s[j]){
      i++;
      j--;
    }else if(s[i] == 'x'){
      i++;
      ans++;
    }else if(s[j] == 'x'){
      j--;
      ans ++;
    }else{
      ans = -1;
      break;
    }
  }
  cout << ans << endl;
}
