#include <iostream>
#include <fstream>
#include <sstream>
#include <string.h>
#include <algorithm>
#include <cmath>
#include <assert.h>
#include <stack>
#include <queue>
#include <list>
#include <vector>
#include <map>
#include <set>

//#define DEBUG 1

#define int long long
#define for0(i,n) for (int i=0; i<n; i++)
#define iter(c) for(auto it=c.begin(); it!=c.end(); it++)
#define iter2(c) for(auto it2=c.begin(); it2!=c.end(); it2++)
#define pb push_back
#define ms(a,z) memset(a,z,sizeof(a));
#define mp make_pair
#define X first
#define Y second
#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))
#define all(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#define pmod(x,m) (((x)%(m)+m)%m)
#ifdef int
#define read(x) scanf("%lld",&x);
#else
#define read(x) scanf("%d",&x);
#endif

#ifdef DEBUG
#define nl cout<<"\n";
#define pr(x) cout<<(x)<<" ";
#define prl(x) cout<<#x " = "<<x<<endl;
#define prp(x) cout<<"("<<(x).first<<" "<<(x).second<<") ";
#define printv(v) {for(int _=0; _<sz(v); _++) cout<<v[_]<<" "; cout<<"\n";}
#define printa(a,s) {for (int _=0; _<s; _++) cout<<a[_]<<" "; cout<<"\n";}
#define print2D(a,m,n) {for (int _=0; _<m; _++) {for (int __=0; __<n; __++) cout<<a[_][__]<<" "; cout<<"\n";} cout<<"\n";}
#define debug cout<<"ok at line "<<__LINE__<<endl;
#else
#define nl
#define pr(x)
#define prl(x)
#define prp(x)
#define printv(v)
#define printa(a,s)
#define print2D(a,m,n)
#define debug
#endif

using namespace std;

typedef long long ll;

const int INF = 2147483647;
const long long INFL = 9223372036854775807LL;
const double EPSILON = 0.00000001;
const long long MOD = 1000000007;

bool is_pal(string nox)
{
    int n = nox.length();
    for (int i=0; i<n/2; i++) {
        if (nox[i] != nox[n-i-1])
            return false;
    }
    return true;
}

int32_t main()
{
    #ifdef DEBUG
    freopen("C.txt","r",stdin);
    //freopen("","w",stdout);
    #endif

    string s;
    cin >> s;
    string nox = "";
    int n = s.length();
    for0(i,n) {
        if (s[i] != 'x')
            nox += s[i];
    }
    
    if (!is_pal(nox)) {
        cout<<-1<<endl;
        return 0;
    }
    
    int l,r;
    if (nox.length() == 0) {
        cout<<0<<endl;
        return 0;
    }
    else if (nox.length()%2 == 0) {
        int cnt = 0;
        for (int i=0; i<n; i++) {
            if (s[i] != 'x') {
                cnt++;
                if (cnt == nox.length()/2)
                    l = i;
                else if (cnt == nox.length()/2+1)
                    r = i;
            }
        }
    }
    else {int cnt = 0;
        for (int i=0; i<n; i++) {
            if (s[i] != 'x') {
                cnt++;
                if (cnt == nox.length()/2+1) {
                    l = r = i;
                    break;
                }
            }
        }
    }
    prl(l) prl(r) 
    
    int ans = 0;
    int i = 0, j = n-1;
    while (i <= l) {
        int cnt1 = 0, cnt2 = 0;
        while (s[i] == 'x') {
            i++;
            cnt1++;
        }
        while (s[j] == 'x') {
            j--;
            cnt2++;
        }
        pr(cnt1) pr(cnt2) nl
        ans += fabs(cnt1-cnt2);
        i++;
        j--;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 640