program main
integer :: n,i
read(*,*)n
do i =1,9
if ((i*100+i*10+i)-100 <= n .and. n <= (i*100+i*10+i)) then
  if (i==1) then
    write(*,*) 222
    exit
  else 
  	write(*,*) 100*i+10*i+i
    exit
  end if
end if
end do
end program