import scala.io.StdIn._

object Main extends App {
  val s = readLine()
  val t = readLine()
  if (t.zip(s).groupBy(_._1).forall(_._2.groupBy(_._2).mapValues(_.toSet.toSeq.length).toSeq.length == 1))
    println("Yes")
  else
    println("No")
}
