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

char s[100005];

int main(){
	scanf("%s", s);
	int l = strlen(s);

	int ans = 0;
	int r = l-1;
	l = 0;
	while(l <= r){
		if(s[l] == 'x' && s[r] != 'x') ans++, l++;
		else if(s[l] != 'x' && s[r] == 'x')  ans++, r--;
		else if(s[l] != s[r]){
			ans = -1;
			break;
		}
		else l++, r--;
	}
	printf("%d\n", ans);
}