let is_uppercase = function
  | 'A' .. 'Z' -> true
  | _ -> false

let toggle_case str =
  let buf = Buffer.create 1024 in
  let len = String.length str in
  let rec iter i = match len-i with
    | 0 -> Buffer.contents buf
    | _ ->
      let c = str.[i] in
      Buffer.add_char buf (if is_uppercase c then Char.lowercase c
                           else Char.uppercase c);
      iter (i+1)
  in iter 0

let () =
  let line = read_line () in
  let toggled = toggle_case line in
  print_endline toggled