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