#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cwchar>
#include <cwctype>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <codecvt>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize("Ofast")
using namespace std;
typedef int64_t ll;
typedef long double ld;
const ll INF=(1LL<<60);
const ld pi=acosl((ld)1);
const ll mod = 1000000007;
const int dx[4]={0,1,0,-1};
const int dy[4]={1,0,-1,0};
const int ddx[8]={1,0,-1,-1,-1,0,1,1};
const int ddy[8]={1,1,1,0,-1,-1,-1,0};

bool solve(){
  string s;cin>>s;
  auto isRot=[](string a){
    string b=a;
    reverse(all(b));
    return a==b;
  };  
  bool isX=true;
  rep(i,s.size()){
    if(s[i]!='x')isX=false;
  }
  if(isX){
    cout<<0<<endl;
    return false;
  }

  string x;
  ll n=s.size();
  rep(i,n)if(s[i]!='x')x.push_back(s[i]);
  // cout<<x<<endl;

  if(!isRot(x)){
    cout<<-1<<endl;
    return false;
  }

  ll m=x.size();
  ll i1=(m-1)/2;
  ll i2=(m)/2;
  // cout<<i1<<" "<<i2<<endl;
  ll index=0;
  string s1;
  string s2;
  bool isLeft=true;
  rep(i,n){
    if(s[i]==x[index]){
      index++;
    }
    if(index<=i1)s1.push_back(s[i]);
    else if(i2<index)s2.push_back(s[i]);
  }
  s1.push_back(x[i1]);
  // cout<<s1<<" "<<s2<<endl;

  /*if((int)x.size()%2==1)s1.push_back(s2[0]);*/
  reverse(all(s1));

  // cout<<s1<<endl;
  // cout<<s2<<endl;
  s1.push_back('a');
  s2.push_back('a');
  vector<ll>v1;
  ll num=0;
  rep(i,s1.size()){
    if(s1[i]=='x')num++;
    else{
      v1.push_back(num);
      num=0;
    }
  }

  vector<ll>v2;
  num=0;
  rep(i,s2.size()){
    if(s2[i]=='x')num++;
    else{
      v2.push_back(num);
      num=0;
    }
  }
  ll ans=0;
  rep(i,v1.size()){
    ans+=abs(v1[i]-v2[i]);
  }

  cout<<ans<<endl;

  return false;
}

signed main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout<<fixed;
	cout<<setprecision(30);
	return solve();
}



Measured memory_bytes: 1772