import math._ import scala.collection.mutable.ArrayBuffer object Main { def calc(s: String) { val xs = new ArrayBuffer[(String, Int)] val buf = new ArrayBuffer[Char] var len = 0 for (c <- s) c match { case 'w' => len += 1 case _ => { if (len > 0 && !buf.isEmpty) { xs.append((buf.mkString, len)) buf.clear } len = 0 buf.append(c) // println(buf) } } if (len > 0 && !buf.isEmpty) xs.append((buf.mkString, len)) if (xs.isEmpty) println() else { val longest = xs.maxBy(_._2)._2 for ((s, _) <- xs.filter(_._2 == longest)) { println(s) } } } def main(args: Array[String]) { val sc = new java.util.Scanner(System.in) val s = sc.nextLine calc(s) } }