let rec chars_of_string = function
  | "" -> []
  | str ->
      String.get str 0 :: chars_of_string (String.sub str 1 (String.length str - 1))

let rec string_of_chars = function
  | [] -> ""
  | c :: tail -> String.make 1 (Char.chr c) ^ string_of_chars tail

(* 比較関数を元に文字列中の文字を並び替える *)
let sort_chars f s =
  string_of_chars @@
    List.sort f @@
      List.map Char.code @@ chars_of_string s

(* 辞書順で最小の文字列に変換 *)
let to_min = sort_chars (-)

(* 辞書順で最大の文字列に変換 *)
let to_max = sort_chars (fun a b -> b - a)

let () =
  let (s, t) = Scanf.scanf "%s\n%s" (fun s t -> (to_min s, to_max t)) in
    print_string @@ if String.compare s t < 0 then "Yes" else "No"
