#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
using namespace std;
const int N=1e5+10;
int n,v[N],len;
char s[N],t[N];
int main(){
	scanf("%s",s+1);n=strlen(s+1);
	for (int i=1;i<=n;++i) 
		if (s[i]=='x') ++v[len];
		else t[++len]=s[i];
	int ans=0;
	for (int i=1;i<=(len+1)>>1;++i) 
		if (t[i]!=t[len-i+1]) return puts("-1"),0;
		else ans+=abs(v[i-1]-v[len-i+1]);
	printf("%d",ans);
	return 0;
}