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;}
  auto l=0, r=s.length-1;
  while(s[l]=='x') l++;
  while(s[r]=='x') r--;

  int f(char[] sub){
    int c1=0;
    foreach(c; sub)if(c!='x') c1++;
    if(c1&1){
      int m=0, c2=0;
      foreach(int i, c; sub){
        if(c!='x') c2++;
        if(c2==c1/2+1){m=i; break;}
      }
      int ret=0;
      for(int i=0; i<m; i++)if(sub[i]=='x'){
        auto j=m+(m-i);
        if(j>=sub.length) ret++;
        else if(sub[i]!=sub[j]) ret++;
      }
      for(auto i=sub.length-1; i>m; i--)if(sub[i]=='x'){
        auto j=m-(i-m);
        if(j<0) ret++;
        else if(sub[j]!=sub[i]) ret++;
      }
      return ret;
    }else{
      long m1, m2, c2=0;
      foreach(int i, c; sub){
        if(c!='x') c2++;
        if(c2==c1/2){m1=i; break;}
      }
      c2=0;
      for(auto i=sub.length-1; i>=0; i--){
        if(sub[i]!='x') c2++;
        if(c2==c1/2){m2=i; break;}
      }
      int l1, r1;
      for(int i=0; i<m1; i++)if(sub[i]=='x') l1++;
      for(auto i=sub.length-1; i>m2; i--)if(sub[i]=='x') r1++;
      int ret=abs((int)l1-(int)r1);
      return ret;
    }
  }

  auto ct=f(s[l..(r+1)]);
  auto n=s.length;
  ct+=abs((int)l-((int)n-(int)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));
  }
}