let () = Scanf.scanf "%d" (fun n -> 
 let a = let rec check_a a' = if 100 * a' - n > 0 then a' - 1 else  check_a (a' + 1) in check_a 2 in
 let b = let rec check_b b' = if 10 * b' - (n - a * 100) > 0 then b' - 1 else  check_b (b' + 1) in check_b 2 in
 let c = let rec check_c c' = if c' - (n - a * 100 - b * 10) > 0 then c' - 1 else  check_c (c' + 1) in check_c 2 in
let chenge m = if m = 1 then 9 else if m = 9 then 1 else m in
let (a', b', c') = (chenge a, chenge b, chenge c) in
let n' = a' * 100 + b' * 10 + c' in
      Printf.printf "%d" n')