object Main { def solve(s: String): Int = { val n = s.length var answer, w1, w2 = Int.MaxValue for (idx <- (n - 1) to 0 by -1) { if (s(idx) == 'w') { w2 = w1 w1 = idx } else if (s(idx) == 'c' && w2 < Int.MaxValue) { answer = scala.math.min(answer, w2 - idx + 1) } } if (answer < Int.MaxValue) { return answer } else { return -1 } } def main(args: Array[String]): Unit = { println(solve(scala.io.StdIn.readLine())) } }