from heapq import heappush, heappop, heapify

from collections import deque, defaultdict, Counter

import itertools

from itertools import permutations, combinations, accumulate

import sys

import bisect

import string

import math

import time





def I(): return int(input())





def S(): return input()





def MI(): return map(int, input().split())





def MS(): return map(str, input().split())





def LI(): return [int(i) for i in input().split()]





def LI_(): return [int(i)-1 for i in input().split()]





def StoI(): return [ord(i)-97 for i in input()]





def ItoS(nn): return chr(nn+97)





def input(): return sys.stdin.readline().rstrip()





def show(*inp, end='\n'):

    if show_flg:

        print(*inp, end=end)





YNL = {False: 'No', True: 'Yes'}

YNU = {False: 'NO', True: 'YES'}

MOD = 10**9+7

inf = float('inf')

IINF = 10**10

l_alp = string.ascii_lowercase

u_alp = string.ascii_uppercase

ts = time.time()

sys.setrecursionlimit(10**6)

nums = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10']



show_flg = False

# show_flg = True





def main():

    s = S()

    d = deque(s)

    ans = 0



    # print(d)



    while len(d) > 1:

        if d[0] == d[-1]:

            d.popleft()

            d.pop()

        elif d[0] == 'x':

            d.append('x')

            ans += 1

        elif d[-1] == 'x':

            d.appendleft('x')

            ans += 1

        else:

            print(-1)

            return



    print(ans)





if __name__ == '__main__':

    main()

from heapq import heappush, heappop, heapify

from collections import deque, defaultdict, Counter

import itertools

from itertools import permutations, combinations, accumulate

import sys

import bisect

import string

import math

import time





def I(): return int(input())





def S(): return input()





def MI(): return map(int, input().split())





def MS(): return map(str, input().split())





def LI(): return [int(i) for i in input().split()]





def LI_(): return [int(i)-1 for i in input().split()]





def StoI(): return [ord(i)-97 for i in input()]





def ItoS(nn): return chr(nn+97)





def input(): return sys.stdin.readline().rstrip()





def show(*inp, end='\n'):

    if show_flg:

        print(*inp, end=end)





YNL = {False: 'No', True: 'Yes'}

YNU = {False: 'NO', True: 'YES'}

MOD = 10**9+7

inf = float('inf')

IINF = 10**19

l_alp = string.ascii_lowercase

u_alp = string.ascii_uppercase

ts = time.time()

sys.setrecursionlimit(10**6)

nums = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10']



show_flg = False

# show_flg = True





def main():

    s = S()

    d = deque(s)

    ans = 0



    while len(d) > 1:

        l = d.popleft()

        r = d.pop()



        if l == r:

            continue

        elif l == 'x':

            ans += 1

            d.append(r)

        elif r == 'x':

            ans += 1

            d.appendleft(l)

        else:

            print(-1)

            return



    print(ans)





if __name__ == '__main__':

    main()

from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations, accumulate
import sys
import bisect
import string
import math
import time


def I():
    return int(input())


def S():
    return input()


def MI():
    return map(int, input().split())


def MS():
    return map(str, input().split())


def LI():
    return [int(i) for i in input().split()]


def LI_():
    return [int(i) - 1 for i in input().split()]


def StoI():
    return [ord(i) - 97 for i in input()]


def ItoS(nn):
    return chr(nn + 97)


def input():
    return sys.stdin.readline().rstrip()


def show(*inp, end="\n"):
    if show_flg:
        print(*inp, end=end)


YNL = {False: "No", True: "Yes"}
YNU = {False: "NO", True: "YES"}
MOD = 10**9 + 7
inf = float("inf")
IINF = 10**10
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
ts = time.time()
sys.setrecursionlimit(10**6)
nums = ["1", "2", "3", "4", "5", "6", "7", "8", "9", "10"]
show_flg = False
# show_flg = True
def main():
    s = S()
    d = deque(s)
    ans = 0
    # print(d)
    while len(d) > 1:
        if d[0] == d[-1]:
            d.popleft()
            d.pop()
        elif d[0] == "x":
            d.append("x")
            ans += 1
        elif d[-1] == "x":
            d.appendleft("x")
            ans += 1
        else:
            print(-1)
            return
    print(ans)


if __name__ == "__main__":
    main()

from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations, accumulate
import sys
import bisect
import string
import math
import time


def I():
    return int(input())


def S():
    return input()


def MI():
    return map(int, input().split())


def MS():
    return map(str, input().split())


def LI():
    return [int(i) for i in input().split()]


def LI_():
    return [int(i) - 1 for i in input().split()]


def StoI():
    return [ord(i) - 97 for i in input()]


def ItoS(nn):
    return chr(nn + 97)


def input():
    return sys.stdin.readline().rstrip()


def show(*inp, end="\n"):
    if show_flg:
        print(*inp, end=end)


YNL = {False: "No", True: "Yes"}
YNU = {False: "NO", True: "YES"}
MOD = 10**9 + 7
inf = float("inf")
IINF = 10**19
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
ts = time.time()
sys.setrecursionlimit(10**6)
nums = ["1", "2", "3", "4", "5", "6", "7", "8", "9", "10"]
show_flg = False
# show_flg = True
def main():
    s = S()
    d = deque(s)
    ans = 0
    while len(d) > 1:
        l = d.popleft()
        r = d.pop()
        if l == r:
            continue
        elif l == "x":
            ans += 1
            d.append(r)
        elif r == "x":
            ans += 1
            d.appendleft(l)
        else:
            print(-1)
            return
    print(ans)


if __name__ == "__main__":
    main()

-IINF = 10**10 +IINF = 10**19 -    # print(d) -        if d[0] == d[-1]: -            d.popleft() -            d.pop() -        elif d[0] == "x": -            d.append("x") +        l = d.popleft() +        r = d.pop() +        if l == r: +            continue +        elif l == "x": -        elif d[-1] == "x": -            d.appendleft("x") +            d.append(r) +        elif r == "x": +            d.appendleft(l)