S = eval(input())

N = len(S)

nx = S.replace('x', '')

N2 = len(nx)

for i in range(N2):

  if nx[i] != nx[N2-i-1]:

    print((-1))

    exit()



if N == N2:

  # x not inclueded

  print((0))

else:

  cnt = 0

  i = 0

  j = N-1

  while i < j:

    if S[i] == 'x':

      if S[j] == 'x':

        i += 1

        j -= 1

      else:

        i += 1

        cnt += 1

    else:

      if S[i] == S[j]:

        i += 1

        j -= 1

      elif S[j] == 'x':

        cnt += 1

        j -= 1

  print(cnt)

      

        

        

  
S = eval(input())

N = len(S)



cnt = 0

i = 0

j = N-1

while i < j:

  if S[i] == 'x':

    if S[j] == 'x':

      i += 1

      j -= 1

    else:

      i += 1

      cnt += 1

  else:

    if S[i] == S[j]:

      i += 1

      j -= 1

    elif S[j] == 'x':

      cnt += 1

      j -= 1

    else:

      print((-1))

      exit()

print(cnt)
S = eval(input())
N = len(S)
nx = S.replace("x", "")
N2 = len(nx)
for i in range(N2):
    if nx[i] != nx[N2 - i - 1]:
        print((-1))
        exit()
if N == N2:
    # x not inclueded
    print((0))
else:
    cnt = 0
    i = 0
    j = N - 1
    while i < j:
        if S[i] == "x":
            if S[j] == "x":
                i += 1
                j -= 1
            else:
                i += 1
                cnt += 1
        else:
            if S[i] == S[j]:
                i += 1
                j -= 1
            elif S[j] == "x":
                cnt += 1
                j -= 1
    print(cnt)

S = eval(input())
N = len(S)
cnt = 0
i = 0
j = N - 1
while i < j:
    if S[i] == "x":
        if S[j] == "x":
            i += 1
            j -= 1
        else:
            i += 1
            cnt += 1
    else:
        if S[i] == S[j]:
            i += 1
            j -= 1
        elif S[j] == "x":
            cnt += 1
            j -= 1
        else:
            print((-1))
            exit()
print(cnt)

-nx = S.replace("x", "") -N2 = len(nx) -for i in range(N2): -    if nx[i] != nx[N2 - i - 1]: -        print((-1)) -        exit() -if N == N2: -    # x not inclueded -    print((0)) -else: -    cnt = 0 -    i = 0 -    j = N - 1 -    while i < j: -        if S[i] == "x": -            if S[j] == "x": -                i += 1 -                j -= 1 -            else: -                i += 1 -                cnt += 1 +cnt = 0 +i = 0 +j = N - 1 +while i < j: +    if S[i] == "x": +        if S[j] == "x": +            i += 1 +            j -= 1 -            if S[i] == S[j]: -                i += 1 -                j -= 1 -            elif S[j] == "x": -                cnt += 1 -                j -= 1 -    print(cnt) +            i += 1 +            cnt += 1 +    else: +        if S[i] == S[j]: +            i += 1 +            j -= 1 +        elif S[j] == "x": +            cnt += 1 +            j -= 1 +        else: +            print((-1)) +            exit() +print(cnt)