object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val N = sc.nextInt()
  val min = 100.to(999)
    .find(i => N <= i && i.toString.toSeq.distinct.length == 1)
    .getOrElse(-1)
  println(min)
}
