#!ruby -Ks
a = gets.to_i
if a > 888
  puts "999"
elsif a > 777
  puts "888"
elsif a > 666
  puts "777"
elsif a > 555
  puts "666"
elsif a > 444
  puts "555"
elsif a > 333
  puts "444"
elsif a > 222
  puts "333"
elsif a > 111
  puts "222"
else
  puts "111"
end