n = gets.chomp.to_i

if n == 111
  puts 999
elsif n == 119
  puts 991
elsif n == 199
  puts 911
elsif n == 191
  puts 919
elsif n == 999
  puts 111
elsif n == 991
  puts 119
elsif n == 911
  puts 199
elsif n == 919
  puts 191
end