module Main where

import Data.List.Split
import Debug.Trace

allDigitsEqual :: Int -> Bool
allDigitsEqual n
  | n < 10 = True
  | otherwise = let
                  x = n `div` 10
                  y = x `mod` 10
                  z = n `mod` 10
                  in y == z && allDigitsEqual x

algorithm :: Int ->  Int
algorithm n = head [x | x <- [n..], allDigitsEqual x]

process :: [String] -> String
process ls = show $ algorithm (read (head ls))

main :: IO ()
main = do
  input <- getContents
  putStrLn $ process (lines input)