void main(){
  import std.stdio, std.string, std.conv, std.algorithm;
  import std.math;

  auto s=readln.chomp.to!(char[]);
  auto t=new char[](0);
  foreach(c; s){
    if(c!='x') t~=c;
  }
  bool ok=true;
  for(int i=0; i<t.length/2; i++){
    ok&=(t[i]==t[$-i-1]);
  }
  if(!ok){writeln(-1); return;}

  int cnt=0;
  foreach(c; s)if(c=='x') cnt++;
  if(cnt==0 || cnt==s.length){writeln(0); return;}
  int l=0, r=s.length-1;
  while(s[l]=='x') l++;
  while(s[r]=='x') r--;

  int f(char[] sub){
    int ret=0;
    for(int i=0; i<sub.length/2; i++){
      if(sub[i]=='x' || sub[$-i-1]=='x'){
        if(sub[i]!=sub[$-i-1]) ret++;
      }
    }
    return ret;
  }

  auto ct=f(s[l..(r+1)]);
  long n=s.length;
  ct+=abs(l-(n-r-1));
  writeln(ct);
}


void rd(T...)(ref T x){
  import std.stdio, std.string, std.conv;
  auto l=readln.split;
  foreach(i, ref e; x){
    e=l[i].to!(typeof(e));
  }
}