open Hashtbl
let s = read_line ()
let t = read_line ()
let n = String.length s
let hs, ht = create n, create n
let f (s, t, h) = String.iteri (fun i c -> replace h c @@ try i :: find h c with _ -> [i]) s;
  iter (fun _ is -> List.(iter (fun j -> if t.[hd is] <> t.[j] then (print_endline "No"; exit 0))) is) h
let _ = List.iter f [(s, t, hs); (t, s, ht)] ; print_endline "Yes"