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

int main(){
  string s;
  cin>>s;
  int N=s.size();
  int ans=0;
  int i=0;
  int j=N-1;
  int out=0;
  while(i<j&&out==0){
    //cout<<i<<" "<<j<<" "<<ans<<endl;
    if(s[i]==s[j]){
      i++;j--;continue;
    }
    if(s[i]=='x'&&s[j]!='x'){
      ans++;i++;continue;
    }
    if(s[i]!='x'&&s[j]=='x'){
      ans++;j--;continue;
    }
    out++;
  }
  if(out)cout<<-1<<endl;
  else cout<<ans<<endl;
}
