#include <bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef pair<int,int>P;
#define F first
#define S second
int main(){
  int ans=0;
  string s,t="";
  cin>>s;
  r(i,s.size())if(s[i]!='x')t+=s[i];
  r(i,t.size()/2){
    if(t[i]!=t[t.size()-1-i]){
      cout<<-1<<endl;
      return 0;
    }
  }
  int l=0,r=s.size()-1;
  while(l<r){
    if(s[l]!=s[r]){
      if(s[l]=='x')l++;
      else r--;
      ans++;
    }
    else r--,l++;
  }
  cout<<ans<<endl;
}