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) =>
          if (memo.isDefinedAt(x) || never.isDefinedAt(x)) {
            if (x == y) {
              println("No")
              break()
            }
          } else {
            if (x != y) {
              memo += (x -> y)
              never += (y -> true)
            }
          }
      })

    println("Yes")
  }
}
