S = eval(input())

N = len(S)

ans = []

check = []

for i in range(N):

    if S[i] != 'x':

        ans.append(S[i])

        check.append(i)

if len(ans) == 0:

    print((0))

    exit()

if ans != ans[::-1]:

    print((-1))

    exit()

if len(ans)%2:

    cl,cr = check[len(ans)//2],check[len(ans)//2]

else:

    cl,cr = check[len(ans)//2-1],check[len(ans)//2]

cnt = 0

while 0 <= cl and cr <= N-1:

    if S[cl] == S[cr]:

        cl -= 1

        cr += 1

    elif S[cl] == 'x':

        cnt += 1

        cl -= 1

    else:

        cnt += 1

        cr += 1

cnt += max(cl+1,N-cr)

print(cnt)

S = eval(input())

N = len(S)

l = 0

r = N-1

ans = 0

while l < r:

    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:

        print((-1))

        exit()

print(ans)



S = eval(input())
N = len(S)
ans = []
check = []
for i in range(N):
    if S[i] != "x":
        ans.append(S[i])
        check.append(i)
if len(ans) == 0:
    print((0))
    exit()
if ans != ans[::-1]:
    print((-1))
    exit()
if len(ans) % 2:
    cl, cr = check[len(ans) // 2], check[len(ans) // 2]
else:
    cl, cr = check[len(ans) // 2 - 1], check[len(ans) // 2]
cnt = 0
while 0 <= cl and cr <= N - 1:
    if S[cl] == S[cr]:
        cl -= 1
        cr += 1
    elif S[cl] == "x":
        cnt += 1
        cl -= 1
    else:
        cnt += 1
        cr += 1
cnt += max(cl + 1, N - cr)
print(cnt)

S = eval(input())
N = len(S)
l = 0
r = N - 1
ans = 0
while l < r:
    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:
        print((-1))
        exit()
print(ans)

-ans = [] -check = [] -for i in range(N): -    if S[i] != "x": -        ans.append(S[i]) -        check.append(i) -if len(ans) == 0: -    print((0)) -    exit() -if ans != ans[::-1]: -    print((-1)) -    exit() -if len(ans) % 2: -    cl, cr = check[len(ans) // 2], check[len(ans) // 2] -else: -    cl, cr = check[len(ans) // 2 - 1], check[len(ans) // 2] -cnt = 0 -while 0 <= cl and cr <= N - 1: -    if S[cl] == S[cr]: -        cl -= 1 -        cr += 1 -    elif S[cl] == "x": -        cnt += 1 -        cl -= 1 +l = 0 +r = N - 1 +ans = 0 +while l < r: +    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 -        cnt += 1 -        cr += 1 -cnt += max(cl + 1, N - cr) -print(cnt) +        print((-1)) +        exit() +print(ans)