#include <bits/stdc++.h>
template <class T>
inline void readin(T &res) {
  static char ch;
  T flag = 1;
  while ((ch = getchar()) < '0' || ch > '9')
    if (ch == '-') flag = -1;
  res = ch - 48;
  while ((ch = getchar()) >= '0' && ch <= '9') res = res * 10 + ch - 48;
  res *= flag;
}
int len, tot, aa[100100], cnt;
char ss[100100];
int main() {
  scanf("%s", ss + 1);
  len = strlen(ss + 1);
  for (int i = 1; i <= len; i++)
    if (ss[i] != 'x') aa[++tot] = i;
  for (int i = 1; i <= tot; i++)
    if (ss[aa[i]] != ss[aa[tot + 1 - i]]) {
      printf("-1\n");
      return 0;
    }
  int i = 1, j = len;
  while (i < j) {
    if (ss[i] == 'x' && ss[j] != 'x')
      cnt++, i++;
    else if (ss[i] != 'x' && ss[j] == 'x')
      cnt++, j--;
    else
      i++, j--;
  }
  printf("%d\n", cnt);
  return 0;
}
