s = eval(input())



s_x = s.replace('x', '')

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

    print((-1))

    exit()



res = 0

l, r = 0, len(s) - 1

while l < r:

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

        l += 1

        r -= 1

    elif s[l] == 'x':

        l += 1

        res += 1

    elif s[r] == 'x':

        r -= 1

        res += 1

    else:

        print((-1))

        exit()

print(res)

s = eval(input())



s_x = s.replace('x', '')

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

    print((-1))

    exit()



res = 0

l, r = 0, len(s) - 1

while l < r:

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

        l += 1

        r -= 1

    elif s[l] == 'x':

        l += 1

        res += 1

    else:

        r -= 1

        res += 1

print(res)

s = eval(input())
s_x = s.replace("x", "")
if s_x != s_x[::-1]:
    print((-1))
    exit()
res = 0
l, r = 0, len(s) - 1
while l < r:
    if s[l] == s[r]:
        l += 1
        r -= 1
    elif s[l] == "x":
        l += 1
        res += 1
    elif s[r] == "x":
        r -= 1
        res += 1
    else:
        print((-1))
        exit()
print(res)

s = eval(input())
s_x = s.replace("x", "")
if s_x != s_x[::-1]:
    print((-1))
    exit()
res = 0
l, r = 0, len(s) - 1
while l < r:
    if s[l] == s[r]:
        l += 1
        r -= 1
    elif s[l] == "x":
        l += 1
        res += 1
    else:
        r -= 1
        res += 1
print(res)

-    elif s[r] == "x": +    else: -    else: -        print((-1)) -        exit()