object Main extends App {
  val Seq(s, t)  = Range(0, 2).map(_ => scala.io.StdIn.readLine)
  var impossible = false
  val map: scala.collection.mutable.Map[Char, Char] = map.empty
  val rmap: scala.collection.mutable.Map[Char, Char] = map.empty
  for(index <- Range(0, s.length)) {
    val Seq(sc, tc) = Seq(s, t).map(s => s(index))
    if(map.getOrElseUpdate(sc, tc) != tc) impossible = true
    if(rmap.getOrElseUpdate(tc, sc) != sc) impossible = true
  }
  println(if(impossible) "No" else "Yes")
}
