object Main {

  def main(args: Array[String]): Unit = {
    val sc = new java.util.Scanner(System.in)
    val chars: Map[Char, Int] = Array(
      'a', 'b', 'c', 'd', 'e', 'f', 'g',
      'h', 'i', 'j', 'k', 'l', 'm', 'n',
      'o', 'p', 'q', 'r', 's', 't', 'u',
      'v', 'w', 'x', 'y', 'z').zipWithIndex.toMap
    val table = scala.collection.mutable.Map.empty[Char, Char]
    val used = new Array[Boolean](26)

    val S, T = scala.io.StdIn.readLine()
    val L = S.length

    // 一度確定した値は変更できない.
    def solve(): Boolean = {
      var i = 0
      while (i < L) {
        table.get(S(i)) match {
          case Some(changed) =>
            println(changed, T(i))
            if (changed != T(i))
              return false
          case None =>
            if (!used(chars.get(T(i)).get)) {
              table.update(S(i), T(i))
              used(chars.get(T(i)).get) = true
            } else
              return false
        }
        i += 1
      }
      true
    }

    println(if (solve()) "Yes" else "No")
  }

}
