let () =
  let s = read_line () in
  let t = read_line () in
  let sort s f =
    let arr = Array.init (String.length s) (fun i -> String.make 1 s.[i]) in
    Array.sort f arr ;
    Array.fold_left (fun x y -> x ^ y) "" arr
  in
  let s = sort s compare in
  let t = sort t (fun x y -> compare y x) in
  (match s < t with true -> "Yes" | false -> "No") |> print_endline
