import java.io.{BufferedOutputStream, BufferedReader, InputStreamReader, PrintWriter}

import scala.collection.mutable
import scala.collection.mutable.ArrayBuffer

object Main {
  def main(args: Array[String]): Unit = {
    val in = new BufferedReader(new InputStreamReader(System.in))
    val out = new PrintWriter(new BufferedOutputStream(System.out))
    val s = in.readLine()
    val t = in.readLine()

    val s2t = mutable.HashMap.empty[Char, Char]
    val t2s = mutable.HashMap.empty[Char, Char]

    for (i <- s.indices) {
      s2t.get(s(i)) match {
        case Some(sit) => if (sit != t(i)) {
          out.println("No")
          out.flush()
          return
        }
        case None => s2t.update(s(i), t(i))
      }
      t2s.get(t(i)) match {
        case Some(tis) => if (tis != s(i)) {
          out.println("No")
          out.flush()
          return
        }
        case None => t2s.update(t(i), s(i))
      }
    }

    out.println("Yes")
    out.flush()
  }
}
