n = gets.to_i
joinNumber = n
(1..9).each do |count|
  tempJoinNumber = 111*count
  break if tempJoinNumber == n
  if n < tempJoinNumber
    joinNumber = tempJoinNumber
    break
  end
end
puts joinNumber