import java.util.Scanner

import scala.annotation.tailrec
import scala.collection.mutable.{Map => MMap}

object Main extends App {
  val sc = new Scanner(System.in)
  val (s, t) = (sc.next.toCharArray, sc.next.toCharArray)
  val s2t = MMap.empty[Char, Char]
  val t2s = MMap.empty[Char, Char]
  var result = true

  @tailrec
  def lp(e: Seq[(Char, Char)]): Unit = {
    e match {
      case (ss, tt) +: rest =>
        val last_s2t = s2t.put(ss, tt)
        val last_t2s = t2s.put(tt, ss)
        if (last_s2t.exists(_ != tt) || last_t2s.exists(_ != ss)) {
          result = false
        } else {
          lp(rest)
        }
      case _ =>
    }
  }

  lp((s zip t).toSeq)

  println(if (result) "Yes" else "No")
}
