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

#define rep(i, n) for(int i = 0;i < n;i++)
#define repr(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)


int main(){
  string s;
  cin>>s;
  int l=0,r=s.size()-1,ans=0;
  while(l<=r){
    if(s[l]!=s[r]&&s[l]!='x'&&s[r]!='x'){ans=-1;
    break;}else if(s[l]==s[r]){
      l++,r--;
    }else if(s[l]=='x'){
      l++,ans++;
    }else{r--,ans++;}
  }
  cout<<ans<<endl;
}