let () =
  let s = read_line () in
  let t = read_line () in
  let sort s f =
    List.init (String.length s) (fun i -> String.make 1 s.[i])
    |> List.sort f
    |> List.fold_left (fun x y -> x ^ y) ""
  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
