object Main {

  def main(args: Array[String]): Unit = {
    val sc = new java.util.Scanner(System.in)

    val S, T = sc.nextLine()
    val to = scala.collection.mutable.Map.empty[Char, Char]
    val res = S.zip(T).forall { case (s, t) =>
      if (to.contains(s)) {
        to(s) == t
      } else {
        to.put(s, t)
        true
      }
    }
    println(if (res) "Yes" else "No")
  }

}