#include <bits/stdc++.h>
using namespace std;

string s;
int ans, l, r;

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