# code-festival-2017-qualcC - Inserting 'x'

from collections import deque





def main():

    S = deque(list(input().rstrip()))

    ans = 0

    while len(S) >= 2:

        l, r = S[0], S[-1]

        if l == r:

            S.popleft(), S.pop()

        else:

            ans += 1

            if l == "x":

                S.append("x")

            elif r == "x":

                S.appendleft("x")

            else:

                print((-1))

                return

    print(ans)





if __name__ == "__main__":

    main()
# code-festival-2017-qualcC - Inserting 'x'

def main():

    S = input().rstrip()

    ans, l, r = 0, 0, len(S) - 1

    while l < r:

        if S[l] == S[r]:

            l += 1

            r -= 1

        else:

            ans += 1

            if S[l] == "x":

                l += 1

            elif S[r] == "x":

                r -= 1

            else:

                print((-1))

                return

    print(ans)





if __name__ == "__main__":

    main()
# code-festival-2017-qualcC - Inserting 'x'
from collections import deque


def main():
    S = deque(list(input().rstrip()))
    ans = 0
    while len(S) >= 2:
        l, r = S[0], S[-1]
        if l == r:
            S.popleft(), S.pop()
        else:
            ans += 1
            if l == "x":
                S.append("x")
            elif r == "x":
                S.appendleft("x")
            else:
                print((-1))
                return
    print(ans)


if __name__ == "__main__":
    main()

# code-festival-2017-qualcC - Inserting 'x'
def main():
    S = input().rstrip()
    ans, l, r = 0, 0, len(S) - 1
    while l < r:
        if S[l] == S[r]:
            l += 1
            r -= 1
        else:
            ans += 1
            if S[l] == "x":
                l += 1
            elif S[r] == "x":
                r -= 1
            else:
                print((-1))
                return
    print(ans)


if __name__ == "__main__":
    main()

-from collections import deque - - -    S = deque(list(input().rstrip())) -    ans = 0 -    while len(S) >= 2: -        l, r = S[0], S[-1] -        if l == r: -            S.popleft(), S.pop() +    S = input().rstrip() +    ans, l, r = 0, 0, len(S) - 1 +    while l < r: +        if S[l] == S[r]: +            l += 1 +            r -= 1 -            if l == "x": -                S.append("x") -            elif r == "x": -                S.appendleft("x") +            if S[l] == "x": +                l += 1 +            elif S[r] == "x": +                r -= 1