#include <algorithm>
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <cstdio>
#include <vector>
#include <bitset>
#include <cmath>
#include <ctime>
#include <queue>
#include <stack>
#include <set>
#include <map>
#define F first
#define S second
#define dq deque
#define vc vector
#define INF ((int)(1e9))
#define LINF ((ll)(1e18))
#define pb push_back
#define mp make_pair
#define ll long long
#define _tp template
#define _tyn typename
#define pf push_front
#define itor iterator
#define sint short int
#define ull unsigned ll
#define pq priority_queue
#define pii pair<int,int>
#define uint unsigned int
#define B cout << "BreakPoint" << endl;
#define ms(_data) memset(_data,0,sizeof(_data))
#define fin(_filename) freopen(_filename,"r",stdin)
#define fout(_filename) freopen(_filename,"w",stdout)
#define msn(_data,_num) memset(_data,_num,sizeof(_data))
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);
using namespace std;
_tp<_tyn T>void mymax( T &_a , T _b ){ if( _a < _b ) _a = _b; }
_tp<_tyn T>void mymin( T &_a , T _b ){ if( _a > _b ) _a = _b; }
void print(int _x){printf("%d ",_x);}
void print(ll _x){printf("%I64d ",_x);}
_tp<_tyn T>void print( T _a[] , int _s , int _t ){
	for( int i = _s ; i <= _t ; i++ )
		cout << _a[i] << " ";
   	cout << endl;
}
#define il inline
struct InputReader{
    static const int bs = 1000000;
    char buf[bs];
    int p;
    InputReader():p(bs) {}
    void flush(){
        p = 0;
        fread(buf, 1, bs, stdin);
    }
    char c(){
        if(p >= bs) flush();
        return buf[p++];
    }
    int operator() (){
        int ans = 0;
        char ch = c();
        while( ch < '0'  ||  ch > '9' ) ch = c();
        while( ch >= '0'  &&  ch <= '9' ){
            ans *= 10;
            ans += ch-'0';
            ch = c();
        }
        return ans;
    }
    void nextlet( int &x ){
    	char ch = c();
    	while( ch < 'a'  ||  ch > 'z' ) ch = c();
    	if( ch == 'c' ) x = 1;
    	if( ch == 'd' ) x = 2;
    	if( ch == 'q' ) x = 3;
	}
	ll readll(){
		ll ans = 0LL;
        char ch = c();
        while( ch < '0'  ||  ch > '9' ) ch = c();
        while( ch >= '0'  &&  ch <= '9' ){
            ans *= 10LL;
            ans += ch-'0';
            ch = c();
        }
        return ans;
	}
}in;
il void read( int &x ){
	x = in();
}
il void read2( int &x, int &y ){
	x = in(); y = in();
}
il void read3( int &x1 , int &x2 , int &x3 ){
	x1 = in(); x2 = in(); x3 = in();
}
/*********************************************************************/
/*********************************************************************/
string s;
int cnt[29];

void ok( int lpos , int rpos , int ans ){
	//cout << lpos << " " << rpos << endl;
	if( lpos == rpos ){
		cout << ans << endl;
		return;
	}
	if( lpos == rpos-1 ){
		if( s[lpos] == s[rpos] ){
			cout << ans << endl;
			return;
		}
		if( s[lpos] == 'x'  ||  s[rpos] == 'x' ){
			cout << ans+1 << endl;
			return;
		}
		cout << (-1) << endl;
		return;
	}
	if( s[lpos] == s[rpos] ){
		ok( lpos+1 , rpos-1 , ans );
		return;
	}
	if( s[lpos] == 'x'  ||  s[rpos] == 'x' ){
		int nlpos = lpos , nrpos = rpos;
		if( s[rpos] == 'x' ) nrpos--;
		else nlpos++;
		ok( nlpos , nrpos , ans+1 );
		return;
	}
	cout << (-1) << endl;
	return;
}

int main(){
	cin >> s;

	ok( 0 , s.length()-1 , 0 );

	return 0;
}


Measured memory_bytes: 512