from collections import deque



s = deque(eval(input()))



ans = 0



while len(s) >= 2:

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

        s.popleft()

        s.pop()

    elif s[0] == "x":

        s.append("x")

        ans += 1

    elif s[-1] == "x":

        s.appendleft("x")

        ans += 1

    else:

        ans = -1

        break



print(ans)
s = eval(input())



l = 0

r = len(s)-1

ans = 0



while r-l >= 1:

    if s[l] == s[r]:

        l += 1

        r -= 1

    elif s[l] == "x":

        l += 1

        ans += 1

    elif s[r] == "x":

        r -= 1

        ans += 1

    else:

        ans = -1

        break



print(ans)
from collections import deque

s = deque(eval(input()))
ans = 0
while len(s) >= 2:
    if s[0] == s[-1]:
        s.popleft()
        s.pop()
    elif s[0] == "x":
        s.append("x")
        ans += 1
    elif s[-1] == "x":
        s.appendleft("x")
        ans += 1
    else:
        ans = -1
        break
print(ans)

s = eval(input())
l = 0
r = len(s) - 1
ans = 0
while r - l >= 1:
    if s[l] == s[r]:
        l += 1
        r -= 1
    elif s[l] == "x":
        l += 1
        ans += 1
    elif s[r] == "x":
        r -= 1
        ans += 1
    else:
        ans = -1
        break
print(ans)

-from collections import deque - -s = deque(eval(input())) +s = eval(input()) +l = 0 +r = len(s) - 1 -while len(s) >= 2: -    if s[0] == s[-1]: -        s.popleft() -        s.pop() -    elif s[0] == "x": -        s.append("x") +while r - l >= 1: +    if s[l] == s[r]: +        l += 1 +        r -= 1 +    elif s[l] == "x": +        l += 1 -    elif s[-1] == "x": -        s.appendleft("x") +    elif s[r] == "x": +        r -= 1