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

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