#include <bits/stdc++.h>
using namespace std;

int main(){
	string s;
	cin>>s;
	int cnt = 0;
	int left = 0, right=s.size()-1;
	while(left < right){
		if(s[left] == s[right]){
			left++;
			right--;
			continue;
		}
		else if(s[left] == 'x' && s[right] != 'x'){
			left++;
			cnt++;
		}
		else if(s[left]!= 'x' && s[right] =='x'){
			right--;
			cnt++;
		}
		else{
			cout<<-1<<endl;
			return 0;
		}
 	}
 	cout<<cnt<<endl;
}