#include <bits/stdc++.h>
using namespace std; // スペル注意
#define rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define pb push_back 
// make_pair など各自で

int main(){
	string S;
	int N;
	cin >> S;
	N = S.size();
	string L ="";
	     for (int i = 0; i < N; i++)
        {
            if (S[i] != 'x')
            {
                L += S[i];
            }
        }
                int M = L.size();
        //WriteLine(L);
        for (int i = 0; i < M / 2; i++)
        {
            if (L[i] != L[M - 1 - i])
            {
                cout << (-1) << endl;
                return 0;
            }
        }
        
        if (M == 0)
        {
            cout << 0 << endl;
        }
        else if (M % 2 == 1)
        {
            int cnt = 0;
            //var A = new int[M / 2 + 1];
            //var B = new int[M / 2 + 1];
            int A[M / 2+ 1] ={0};
            int B[M /2 + 1]= {0};
            for (int i = 0; i < N; i++)
            {
                if (S[i] != 'x')
                {
                    cnt++;
                }
                else
                {
                    if (cnt <= M / 2)
                    {
                        A[M / 2 - cnt]++;
                    }
                    else
                    {
                        B[cnt - M / 2 - 1]++;
                    }
                }


            }
            long sum = 0;
            //WriteLine(string.Join(" ", A));
            //WriteLine(string.Join(" ", B));
            for (int i = 0; i < M / 2 + 1; i++)
            {
                sum += abs(A[i] - B[i]);
            }
            cout << sum << endl;


        }
        else
        {
            int cnt = 0;
            //var A = new int[M / 2];
            //var B = new int[M / 2];
           int A[M / 2] ={0};
            int B[M /2] ={0};
            for (int i = 0; i < N; i++)
            {
                if (S[i] != 'x')
                {
                    cnt++;
                }
                else
                {
                    if (cnt <= M / 2 - 1)
                    {
                        A[M / 2 - cnt - 1]++;
                    }
                    else if(cnt >= M / 2 + 1)
                    {
                        B[cnt - M / 2 - 1]++;
                    }
                }


            }
            long sum = 0;
            //WriteLine(string.Join(" ", A));
            //WriteLine(string.Join(" ", B));
            for (int i = 0; i < M / 2; i++)
            {
                sum += abs(A[i] - B[i]);
            }
            cout << sum << endl;
        }
	return 0;
}