let s = read_line () in
let t = read_line () in
let sa = Array.init (String.length s) (fun i -> s.[i]) in
let ta = Array.init (String.length t) (fun i -> t.[i]) in
let () = Array.sort (fun a b -> compare a b) sa in
let () = Array.sort (fun a b -> compare b a) ta in
let s = String.init (String.length s) (fun i -> sa.(i)) in
let t = String.init (String.length t) (fun i -> ta.(i)) in
print_endline @@ if s < t then "Yes" else "No"