n = gets.chop.to_i

available = Array.new
for i in 1..9
	number = (i.to_s * 3).to_i
	available.push(number)
end

ok = 0 
i = 0
while ok == 0 && i < 9 do
	if n <= available[i]
		ok = 1
		puts available[i]
	end
	i += 1
end