s = eval(input())

ans = 0

while s:

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

        s = s[1:-1]

    elif s[0] == 'x':

        s = s[1:]

        ans += 1

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

        s = s[:-1]

        ans += 1

    else:

        ans = -1

        break

print(ans)

# https://img.atcoder.jp/code-festival-2017-qualc/editorial.pdf

s = eval(input())

ans = 0

lb = 0

rb = len(s) - 1

while rb - lb > 0:

    if s[lb] == s[rb]:

        lb += 1

        rb -= 1

    elif s[lb] == 'x':

        lb += 1

        ans += 1

    elif s[rb] == 'x':

        rb -= 1

        ans += 1

    else:

        ans = -1

        break

print(ans)

# https://img.atcoder.jp/code-festival-2017-qualc/editorial.pdf

s = eval(input())
ans = 0
while s:
    if s[0] == s[-1]:
        s = s[1:-1]
    elif s[0] == "x":
        s = s[1:]
        ans += 1
    elif s[-1] == "x":
        s = s[:-1]
        ans += 1
    else:
        ans = -1
        break
print(ans)
# https://img.atcoder.jp/code-festival-2017-qualc/editorial.pdf

s = eval(input())
ans = 0
lb = 0
rb = len(s) - 1
while rb - lb > 0:
    if s[lb] == s[rb]:
        lb += 1
        rb -= 1
    elif s[lb] == "x":
        lb += 1
        ans += 1
    elif s[rb] == "x":
        rb -= 1
        ans += 1
    else:
        ans = -1
        break
print(ans)
# https://img.atcoder.jp/code-festival-2017-qualc/editorial.pdf

-while s: -    if s[0] == s[-1]: -        s = s[1:-1] -    elif s[0] == "x": -        s = s[1:] +lb = 0 +rb = len(s) - 1 +while rb - lb > 0: +    if s[lb] == s[rb]: +        lb += 1 +        rb -= 1 +    elif s[lb] == "x": +        lb += 1 -    elif s[-1] == "x": -        s = s[:-1] +    elif s[rb] == "x": +        rb -= 1