n = gets.to_i

test = 0

array = [111, 222, 333, 444, 555, 666, 777, 888, 999]

array.each_with_index do |item, idx|
  if array[idx] == n
    test = n
    break
  end
  if (array[idx] < n) && (array[idx+1] > n)
    test = array[idx+1]
    break
  end
end

puts test
