#include <string>

#include <iostream>

using namespace std;

int main(){
	int c=0;
	string s;

	cin >> s;

	int left=0, right;
	right=(int)s.size() - 1;


	while(left < right){
		if(s[left] == s[right]){
			left++;
			right--;
		}else if(s[left] == 'x'){
			left++;
			c++;
		}else if(s[right] == 'x'){
			right--;
			c++;
		}else{
			cout << -1 << endl;
			return 0;
		}
	}

	cout << c << endl;

	return 0;
}