import scala.util.control.Breaks._

object Main extends App {
  val s = scala.io.StdIn.readLine()
  val t = scala.io.StdIn.readLine()

  var memo = Map[Char, Char]()

  breakable {
    s.zip(t)
      .foreach({
        case (x, y) =>
          if (memo.isDefinedAt(x)) {
            if (memo(x) != y) {
              println("No")
              break()
            }
          } else {
            memo += (x -> y)
          }
      })

    if (memo.values.size == memo.values.toList.distinct.size) {
      println("Yes")
    } else {
      println("No")
    }
  }
}
