#include <bits/stdc++.h>
using namespace std;
const int INF = (INT_MAX / 2);
const long long LLINF = (LLONG_MAX / 2);
const double eps = 1e-5;
const double PI = M_PI;
inline long long pow(long long x, long long n, long long m) {
  long long r = 1;
  while (n > 0) {
    if ((n & 1) == 1) r = r * x % m;
    x = x * x % m;
    n >>= 1;
  }
  return r % m;
}
bool check(string s) {
  for (long long i = 0; i < (s.size() / 2); i++) {
    if (s[i] != s[s.size() - 1 - i]) return false;
  }
  return true;
}
int main() {
  string s;
  cin >> s;
  string con = s;
  int x_cnt = 0;
  int cnt = 0;
  for (long long i = 0; i < (con.size()); i++)
    if (con[i] == 'x') {
      con.erase(i, 1), i--;
      x_cnt++;
    } else {
      cnt++;
    }
  if (check(con)) {
    int ans = 0;
    string ss = s;
    reverse((ss).begin(), (ss).end());
    for (int i = 0; s.size() != ss.size() || i < (int)ss.size() / 2; i++) {
      if (ss[i] == 'x' && s[i] == 'x')
        continue;
      else if (ss[i] == 'x') {
        ans++;
        ss.erase(i, 1);
        i--;
      } else if (s[i] == 'x') {
        ans++;
        s.erase(i, 1);
        i--;
      }
    }
    cout << ans << endl;
  } else
    cout << -1 << endl;
  return 0;
}
