main :: IO()
main = do
    n <- readLn
    print $ head $ [x | x <- [n..999], getsolve x]

--全部の桁が同じかどうか判定
getsolve :: Int -> Bool
getsolve num
    | num < 10				= True
    | sita1 == sita2		= getsolve $ div num 10
    | otherwise				= False
    where sita1 = num `mod` 10
          sita2 = (num `div` 10) `mod` 10