fun main(args : Array<String>) {
    val s = readLine()!!

    var lIdx = 0
    var rIdx = s.length-1
    var cnt = 0

    while (lIdx <= rIdx) {
        if (s[lIdx] == s[rIdx]) {
            lIdx++
            rIdx--
            continue
        }

        if (s[lIdx] == 'x') {
            cnt++
            lIdx++
            continue
        }

        if (s[rIdx] == 'x') {
            cnt++
            rIdx--
            continue
        }

        println(-1)
        return
    }

    println(cnt)
}