program code_festival_2017_qualc_c
    use,intrinsic :: iso_fortran_env
    implicit none
    character(100000):: s, nox_s
    integer(int32):: ls, lnxs,i,j,ans

    read*, s
    ls = len_trim(s)
    nox_s = ''
    do i=1,ls
        if (s(i:i) == 'x') cycle
        nox_s = trim(nox_s) // s(i:i)
    end do
    lnxs = len_trim(nox_s)
    i=1
    j=lnxs

    do while(i <= j)
        if (nox_s(i:i) /= nox_s(j:j)) then
            print'(i0)', -1
            stop
        end if
        i=i+1
        j=j-1
    end do

    ans=0
    i=1
    j=ls
    do while(i <= j)
        if (s(i:i) == s(j:j)) then
            i=i+1
            j=j-1
            cycle
        else if (s(i:i) == 'x') then
            ans=ans+1
            i=i+1
        else
            j=j-1
            ans=ans+1
        end if
    end do
    print'(i0)', ans
end program code_festival_2017_qualc_c