import Data.List as L
import Data.Char as C
main=do
    n<-getLine::IO[Char]
    print $ if (L.foldl' (\a c-> a && (head n) >= c) True (tail n)) then C.digitToInt (head n)*111 else  (C.digitToInt (head n) + 1)*111