#include<bits/stdc++.h>
using namespace std;
int main()
{
	string s;
	int ans=0;
	cin>>s;
	int n=s.size();
	int l=0; int r=n-1;
	while(l<=r)
	{
		if(s[l]==s[r])
		{
			l++; r--;
			continue;
		}
		if(s[l]!='x' && s[r]!='x')
		{
			cout<<-1<<endl;
			return 0;
		}
		if(s[l]=='x')
		{
			l++;
			ans++;
			continue;
		}
		if(s[r]=='x')
		{
			r--;;
			ans++;
			continue;
		}
	}
	cout<<ans<<endl;
	return 0;
}