#include<bits/stdc++.h>

using namespace std;

#define ll long long

int main() {
    string s;
    cin>>s;
    int n=s.size();
    int i=0,j=n-1;
    int ans=0;
    while(i<j) {
        if(s[i]==s[j]) i++,j--;
        else if(s[i]=='x') i++,ans++;
        else if(s[j]=='x') j--,ans++;
        else {
            ans=-1; break;
        }
    }
    cout<<ans<<endl;
    
    return 0;
}
