#include <bits/stdc++.h>

using namespace std;

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