import sys



sys.setrecursionlimit(10 ** 7)

f_inf = float('inf')

mod = 10 ** 9 + 7





def resolve():

    s = eval(input())

    ss = []

    for i in s:

        if i != "x":

            ss.append(i)



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

        print((-1))

    else:

        n = len(ss) + 1

        cnt = 0

        cnt_x = [0] * (n)

        pos = 0

        for i in range(len(s)):

            if s[i] == "x":

                cnt += 1



            if s[i] != "x" or i == len(s) - 1:

                cnt_x[pos] = cnt

                cnt = 0

                pos += 1



        res = 0

        for i in range(n // 2):

            res += abs(cnt_x[i] - cnt_x[-(i + 1)])



        print(res)





if __name__ == '__main__':

    resolve()

import sys



sys.setrecursionlimit(10 ** 7)

f_inf = float('inf')

mod = 10 ** 9 + 7





def resolve():

    s = eval(input())

    n = len(s)

    ss = "".join(s.replace("x", ""))

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

        print((-1))

        exit()



    res = 0

    left = 0

    right = n - 1

    while left <= right:

        if s[left] == s[right]:

            left += 1

            right -= 1

        else:

            if s[left] == "x":

                left += 1

            else:

                right -= 1

            res += 1

    print(res)





if __name__ == '__main__':

    resolve()

import sys

sys.setrecursionlimit(10**7)
f_inf = float("inf")
mod = 10**9 + 7


def resolve():
    s = eval(input())
    ss = []
    for i in s:
        if i != "x":
            ss.append(i)
    if ss != ss[::-1]:
        print((-1))
    else:
        n = len(ss) + 1
        cnt = 0
        cnt_x = [0] * (n)
        pos = 0
        for i in range(len(s)):
            if s[i] == "x":
                cnt += 1
            if s[i] != "x" or i == len(s) - 1:
                cnt_x[pos] = cnt
                cnt = 0
                pos += 1
        res = 0
        for i in range(n // 2):
            res += abs(cnt_x[i] - cnt_x[-(i + 1)])
        print(res)


if __name__ == "__main__":
    resolve()

import sys

sys.setrecursionlimit(10**7)
f_inf = float("inf")
mod = 10**9 + 7


def resolve():
    s = eval(input())
    n = len(s)
    ss = "".join(s.replace("x", ""))
    if ss != ss[::-1]:
        print((-1))
        exit()
    res = 0
    left = 0
    right = n - 1
    while left <= right:
        if s[left] == s[right]:
            left += 1
            right -= 1
        else:
            if s[left] == "x":
                left += 1
            else:
                right -= 1
            res += 1
    print(res)


if __name__ == "__main__":
    resolve()

-    ss = [] -    for i in s: -        if i != "x": -            ss.append(i) +    n = len(s) +    ss = "".join(s.replace("x", "")) -    else: -        n = len(ss) + 1 -        cnt = 0 -        cnt_x = [0] * (n) -        pos = 0 -        for i in range(len(s)): -            if s[i] == "x": -                cnt += 1 -            if s[i] != "x" or i == len(s) - 1: -                cnt_x[pos] = cnt -                cnt = 0 -                pos += 1 -        res = 0 -        for i in range(n // 2): -            res += abs(cnt_x[i] - cnt_x[-(i + 1)]) -        print(res) +        exit() +    res = 0 +    left = 0 +    right = n - 1 +    while left <= right: +        if s[left] == s[right]: +            left += 1 +            right -= 1 +        else: +            if s[left] == "x": +                left += 1 +            else: +                right -= 1 +            res += 1 +    print(res)