from collections import Counter



s = eval(input())

snotx = "".join([ch for ch in s if ch != 'x'])



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

    print((0))

    exit()



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

    print((-1))

    exit()



# 回数を合わせる

# print(s)

# print(snotx)



# xのrun-length

rl = []

i = 0

while i < len(s): 

    j = i

    while j < len(s) and s[j] == 'x':

        j += 1

    rl.append(j - i)

    i = j + 1

if s[-1] != 'x':

    rl.append(0)



# run-lengthの左右を見て合わせる

res = 0

i = 0

while i * 2 < len(rl):

    res += max(rl[i], rl[len(rl) - i - 1]) - min(rl[i], rl[len(rl) - i - 1])

    i += 1

print(res)

from collections import Counter



s = eval(input())

snotx = "".join([ch for ch in s if ch != 'x'])



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

    print((0))

    exit()



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

    print((-1))

    exit()



# 両端から見てくる (解説解法)

index_l = 0

index_r = len(s) - 1

count = 0

while index_l < index_r:

    if s[index_l] == s[index_r]:

        index_l += 1

        index_r -= 1

    elif s[index_l] == 'x':

        count += 1

        index_l += 1

    elif s[index_r] == 'x':

        count += 1

        index_r -= 1

    else:

        print((-1))

        exit()

print(count)
from collections import Counter

s = eval(input())
snotx = "".join([ch for ch in s if ch != "x"])
if s == s[::-1]:
    print((0))
    exit()
if snotx != snotx[::-1]:
    print((-1))
    exit()
# 回数を合わせる
# print(s)
# print(snotx)
# xのrun-length
rl = []
i = 0
while i < len(s):
    j = i
    while j < len(s) and s[j] == "x":
        j += 1
    rl.append(j - i)
    i = j + 1
if s[-1] != "x":
    rl.append(0)
# run-lengthの左右を見て合わせる
res = 0
i = 0
while i * 2 < len(rl):
    res += max(rl[i], rl[len(rl) - i - 1]) - min(rl[i], rl[len(rl) - i - 1])
    i += 1
print(res)

from collections import Counter

s = eval(input())
snotx = "".join([ch for ch in s if ch != "x"])
if s == s[::-1]:
    print((0))
    exit()
if snotx != snotx[::-1]:
    print((-1))
    exit()
# 両端から見てくる (解説解法)
index_l = 0
index_r = len(s) - 1
count = 0
while index_l < index_r:
    if s[index_l] == s[index_r]:
        index_l += 1
        index_r -= 1
    elif s[index_l] == "x":
        count += 1
        index_l += 1
    elif s[index_r] == "x":
        count += 1
        index_r -= 1
    else:
        print((-1))
        exit()
print(count)

-# 回数を合わせる -# print(s) -# print(snotx) -# xのrun-length -rl = [] -i = 0 -while i < len(s): -    j = i -    while j < len(s) and s[j] == "x": -        j += 1 -    rl.append(j - i) -    i = j + 1 -if s[-1] != "x": -    rl.append(0) -# run-lengthの左右を見て合わせる -res = 0 -i = 0 -while i * 2 < len(rl): -    res += max(rl[i], rl[len(rl) - i - 1]) - min(rl[i], rl[len(rl) - i - 1]) -    i += 1 -print(res) +# 両端から見てくる (解説解法) +index_l = 0 +index_r = len(s) - 1 +count = 0 +while index_l < index_r: +    if s[index_l] == s[index_r]: +        index_l += 1 +        index_r -= 1 +    elif s[index_l] == "x": +        count += 1 +        index_l += 1 +    elif s[index_r] == "x": +        count += 1 +        index_r -= 1 +    else: +        print((-1)) +        exit() +print(count)