open Printf
open Scanf

let id x = x
let pair x y = x, y

let s, t = scanf "%s %s" pair
let n = String.length s

let t = String.uppercase t

let tbl = Hashtbl.create 50

let swap c1 c2 s =
  String.iteri (fun i c -> if c = c1 then s.[i] <- '*') s;
  String.iteri (fun i c -> if c = c2 then s.[i] <- c1) s;
  String.iteri (fun i c -> if c = '*' then s.[i] <- c2) s

let () =
  for i = 0 to n - 1 do
    if not (Hashtbl.mem tbl s.[i]) then begin
      Hashtbl.add tbl s.[i] true;
      swap s.[i] t.[i] s
    end
  done;
  print_endline @@ if s = t then "Yes" else "No"
