package Yukicoder /** * Created by hichikawa on 2015/11/12. */ fun main(args: Array) { fun readLineLongArray(): List { val str = readLine() as String val arrStr = str.split(" ") val ret = arrStr.map { it.toLong() } return ret } fun readLineLong(): Long { val str = readLine() as String return str.toLong() } fun readLineInt(): Int { val str = readLine() as String return str.toInt() } fun readLineIntArray() : List { val str = readLine() as String val arrStr = str.split(" ") val ret = arrStr.map { it.toInt() } return ret } fun readLineDoubleArray(): List { val str = readLine() as String val arrStr = str.split(" ") val ret = arrStr.map { it.toDouble() } return ret } fun checkKai(str : String , startIndex : Int, endIndex : Int) : Boolean{ for (i in 0..((endIndex-startIndex)/2)) { if (str.get(startIndex+i) != str.get(endIndex-i)) { return false } } return true } val inputStr = readLine() as String var maxI = Int.MIN_VALUE for ((i, ch) in inputStr.withIndex()) { // var lastIndex = inputStr.length var lastIndex = if (i != 0) inputStr.length else inputStr.length-1 do { lastIndex = inputStr.lastIndexOf(inputStr[i], lastIndex-1) if (checkKai(inputStr, i, lastIndex)) { // println((lastIndex-i).toString() + " " + i + " " + lastIndex) if (maxI <= (lastIndex-i)) { maxI = lastIndex-i+1 } break } } while (i < lastIndex) } println(maxI) }