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

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