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

cout<<br<<endl;
return 0;
}
