
type ABC(stream:System.IO.TextReader) =
  member this.Scan1 f = stream.ReadLine() |> f
  member this.Scan2 f = stream.ReadLine().Split() |> Array.map f |> (fun a -> (a.[0], a.[1]))
  member this.Scan3 f = stream.ReadLine().Split() |> Array.map f |> (fun a -> (a.[0], a.[1], a.[2]))
  member this.Scan4 f = stream.ReadLine().Split() |> Array.map f |> (fun a -> (a.[0], a.[1], a.[2], a.[3]))
  member this.ScanVecH f = stream.ReadLine().Split() |> Array.map f
  member this.ScanVecV n f = [| for i in 1..n -> stream.ReadLine() |> f |]
  member this.ScanMatrix n f  = [| for i in 1..n -> stream.ReadLine().Split() |> Array.map f |]
  member this.ScanCharMatrix n = [| for i in 1..n -> stream.ReadLine().ToCharArray() |]
  member this.Close () = stream.Close()

let util = ABC(stdin)

let S = util.Scan1 (fun s -> s.ToCharArray())
let T = util.Scan1 (fun s -> s.ToCharArray())
let dicS = Array.init 26 (fun _ -> -1)
let dicT = Array.init 26 (fun _ -> -1)

let rec rfn xs =
  match xs with
  | [] -> true
  | i::xs ->
      let s = (int S.[i]) - (int 'a')
      let t = (int T.[i]) - (int 'a')
      do if dicS.[s] = -1 then Array.set dicS s t
         if dicT.[t] = -1 then Array.set dicT t s
      match t = dicS.[s], s = dicT.[t] with
      | true, true -> rfn xs 
      | _ -> false

if S.Length <> T.Length
then
  printfn "No"
else
  if rfn [0..S.Length-1]
  then printfn "Yes"
  else printfn "No"

util.Close()
