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