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]()
  var never = Map[Char, Boolean]()

  breakable {
    s.zip(t)
      .foreach({
        case (x, y) =>
          memo += (x -> y)
      })

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