program prob5
    implicit none
    character(len=100005)::S
    integer::l(500000)
    integer::m, i, j, tmp, ans
    read(*,*) S
    m = len_trim(S)
    tmp = 200000
    l = 0
    j = 1
    do i = 1, m
        if(S(i:i) .eq. "x") then
            tmp = tmp + 1
        else
            l(j) = tmp
            l(j+1) = ichar(S(i:i)) - ichar('a')
            tmp = 200000
            j = j+2
        end if
    end do
    l(j) = tmp
    !write(*,*) j

    ans = 0
    do i = 1, j/2
        if(mod(i,2) == 1) then
            ans = ans + abs(l(i) - l(j-i+1))
        else
            if(l(i) /= l(j-i+1)) then
                write(*,*) -1
                stop
            end if
        end if
    end do

    write(*,*) ans
    stop
end program