import sys

input = sys.stdin.readline





def main():

    s = input().strip()

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

    ans = 0

    while l < r:

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

            l += 1

            r -= 1

        elif s[l] == "x" and s[r] != "x":

            ans += 1

            l += 1

        elif s[l] != "x" and s[r] == "x":

            ans += 1

            r -= 1

        else:

            print((-1))

            return

    print(ans)





if __name__ == '__main__':

    main()

import sys

input = sys.stdin.readline





def main():

    s = input().strip()

    import collections

    q = collections.deque(s)

    ans = 0

    while q:

        s, t = q[0], q[-1]

        if s == t:

            q.popleft()

            if q:

                q.pop()

        elif s == "x" and t != "x":

            ans += 1

            q.popleft()

        elif s != "x" and t == "x":

            ans += 1

            q.pop()

        else:

            print((-1))

            return

    print(ans)





if __name__ == '__main__':

    main()

import sys

input = sys.stdin.readline


def main():
    s = input().strip()
    l, r = 0, len(s) - 1
    ans = 0
    while l < r:
        if s[l] == s[r]:
            l += 1
            r -= 1
        elif s[l] == "x" and s[r] != "x":
            ans += 1
            l += 1
        elif s[l] != "x" and s[r] == "x":
            ans += 1
            r -= 1
        else:
            print((-1))
            return
    print(ans)


if __name__ == "__main__":
    main()

import sys

input = sys.stdin.readline


def main():
    s = input().strip()
    import collections

    q = collections.deque(s)
    ans = 0
    while q:
        s, t = q[0], q[-1]
        if s == t:
            q.popleft()
            if q:
                q.pop()
        elif s == "x" and t != "x":
            ans += 1
            q.popleft()
        elif s != "x" and t == "x":
            ans += 1
            q.pop()
        else:
            print((-1))
            return
    print(ans)


if __name__ == "__main__":
    main()

-    l, r = 0, len(s) - 1 +    import collections + +    q = collections.deque(s) -    while l < r: -        if s[l] == s[r]: -            l += 1 -            r -= 1 -        elif s[l] == "x" and s[r] != "x": +    while q: +        s, t = q[0], q[-1] +        if s == t: +            q.popleft() +            if q: +                q.pop() +        elif s == "x" and t != "x": -            l += 1 -        elif s[l] != "x" and s[r] == "x": +            q.popleft() +        elif s != "x" and t == "x": -            r -= 1 +            q.pop()