#include "cstdio"
#include "iostream"
#include "string"
using namespace std;
string s;int i,j,ss,k;
int main(){
	cin>>s;
	i=s.size()-1;
	while(j<=i){
		if(s[j]==s[i]){
			j++,i--;continue;
		}
		else if(s[j]=='x'){
			j++,ss++;continue;
		}
		else if(s[i]=='x'){
			i--,ss++;continue;
		}
		else{
			printf("-1\n");return 0;
		}
	}
	printf("%d\n",ss);
}