import Control.Applicative
import Control.Monad
import Data.List
import Data.Array
import Data.Char

main = do
  n <- (read::String -> Int) <$> getLine
  print $ minimum $ filter ((<=) n) $ map (\i -> i * 100 + i * 10 + i) [1..9]

