program ABC111B
    implicit none
    integer(8)::i
    integer(8)::N

    read(5,*)N

    do i=1,9
        if(100*i+10*i+i>=N)then
            exit
        end if
    end do

    print'(i0)',100*i+10*i+i
    
end program ABC111B