solve :: Int -> Int
solve n
  | oh == t && t == o = n
  | oh >= t && t >= o = oh * 100 + oh * 10 + oh
  | otherwise = (oh + 1) * 100 + (oh + 1) * 10 + (oh + 1)
  where
    oh = n `div` 100
    t = (n - (100 * oh)) `div` 10
    o = n - 100 * oh - 10 * t

main = do
  n <- readLn
  let ans = solve n
  print ans