#include <bits/stdc++.h>

using namespace std;

int main(void) {
  string s;
  cin >> s;

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

  return 0;
}