program prob5
    implicit none
    integer :: i, j, L, ans, m, n
    character(100005) :: s
    character(1) :: a, b
    read(*,*) s
    L = len_trim(s)

    i = 0
    j = L+1
    ans = 0
    do while(.true.)
        m = 0
        n = 0
        i = i + 1
        j = j - 1
        do while(.true.)
            if(i > L)then
                a = 'x'
                exit
            end if
            if(s(i:i) == 'x')then
                m = m + 1
                i = i + 1
            else
                a = s(i:i)
                exit
            end if
        end do
        do while(.true.)
            if(j < 1)then
                b = 'x'
                exit
            end if
            if(s(j:j) == 'x')then
                n = n + 1
                j = j - 1
            else
                b = s(j:j)
                exit
            end if
        end do        

        if(a /= b)then
            write(*,*) -1
            stop
        end if
        
        ans = ans + abs(m - n)

        if(i > L .or. j < 1)then
            exit
        end if
        
    end do

    write(*,*) ans/2

    stop
contains
end program prob5