un main(args: Array<String>) {
    var array = readLine()!!.toCharArray().map {it.toString().toInt()}.toMutableList()
    var count = 0
    while (true) {
        val prev = array
        array = check(array)
        println(array)
        count += 2
        if (array.equals(prev)) {
            break
        }
    }
    print(count - 2)
}

fun check(list: MutableList<Int>): MutableList<Int> {
    for (i in 0..list.size - 2) {
        if (list[i] != list[i + 1]) {
            val newList = list.toMutableList()
            newList.remove(i)
            newList.remove(i + 1)
            return newList
        }
    }
    return list
}