(* O(n) (n = |s|) *)
let string_to_char_array s = Array.init (String.length s) (fun i -> s.[i])

(* O(n) (n = |cs|) *)
let char_array_to_string cs = String.init (Array.length cs) (fun i -> cs.(i))

(* O(n * log(n)) (n = |s|) *)
let string_sort cmp s =
  let cs = string_to_char_array s in
  Array.sort cmp cs;
  char_array_to_string cs

(* O(n * log(n)) (n = max {|s|, |t|}) *)
let solve s t =
  if string_sort compare s < string_sort (fun x y -> compare x y * -1) t then
    "Yes"
  else
    "No"

let _ =
  let s = read_line () in
  let t = read_line () in
  solve s t |> print_endline