s = eval(input())

t= "".join(c for c in s if c!="x")

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

    print((-1))

else:

    ans=0

    i=0

    j=0

    l=len(s)

    while i+j<l-1:

        if s[i] != s[l-1-j]:

            ans+=1

            if s[i] == "x" : i+=1

            else : j+=1

        else:

            i+=1

            j+=1

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

t = "".join(s.split("x"))

if t!=t[::-1]:print((-1));exit()

ans = 0

i,j=0,len(s)-1

while i<j:

    if s[i]==s[j]:i+=1;j-=1

    elif s[i]=="x":ans+=1;i+=1

    elif s[j]=="x":ans+=1;j-=1

print(ans)
s = eval(input())
t = "".join(c for c in s if c != "x")
if t != t[::-1]:
    print((-1))
else:
    ans = 0
    i = 0
    j = 0
    l = len(s)
    while i + j < l - 1:
        if s[i] != s[l - 1 - j]:
            ans += 1
            if s[i] == "x":
                i += 1
            else:
                j += 1
        else:
            i += 1
            j += 1
    print(ans)

s = eval(input())
t = "".join(s.split("x"))
if t != t[::-1]:
    print((-1))
    exit()
ans = 0
i, j = 0, len(s) - 1
while i < j:
    if s[i] == s[j]:
        i += 1
        j -= 1
    elif s[i] == "x":
        ans += 1
        i += 1
    elif s[j] == "x":
        ans += 1
        j -= 1
print(ans)

-t = "".join(c for c in s if c != "x") +t = "".join(s.split("x")) -else: -    ans = 0 -    i = 0 -    j = 0 -    l = len(s) -    while i + j < l - 1: -        if s[i] != s[l - 1 - j]: -            ans += 1 -            if s[i] == "x": -                i += 1 -            else: -                j += 1 -        else: -            i += 1 -            j += 1 -    print(ans) +    exit() +ans = 0 +i, j = 0, len(s) - 1 +while i < j: +    if s[i] == s[j]: +        i += 1 +        j -= 1 +    elif s[i] == "x": +        ans += 1 +        i += 1 +    elif s[j] == "x": +        ans += 1 +        j -= 1 +print(ans)