object Main {
  import java.util.Scanner
  import scala.collection.mutable

  def readStrings(n: Int)(implicit sc: Scanner): Array[String] = Array.fill(n) { sc.next() }
  def readInts(n: Int)(implicit sc: Scanner): Array[Int] = Array.fill(n) { sc.nextInt() }
  def readLongs(n: Int)(implicit sc: Scanner): Array[Long] = Array.fill(n) { sc.nextLong() }
  def readLineStrings(implicit sc: Scanner): Array[String] = sc.nextLine().split(' ')
  def readLineInts(implicit sc: Scanner): Array[Int] = readLineStrings.map(_.toInt)
  def readLineLongs(implicit sc: Scanner): Array[Long] = readLineStrings.map(_.toLong)

  def main(args: Array[String]): Unit = solve(new Scanner(System.in))

  def embeddable(S: String, T: String): Boolean = {
    val correspondence = mutable.HashMap.empty[Char, Char]
    S.zip(T).forall { case (s, t) =>
      correspondence.get(s) match {
        case Some(t1) => t == t1
        case None =>
          correspondence(s) = t
          true
      }
    }
  }

  def solve(implicit sc: Scanner): Unit = {
    val S = sc.nextLine()
    val T = sc.nextLine()
    if (embeddable(S, T) && embeddable(T, S)) println("Yes") else println("No")
  }
}
