import scala.io.{StdIn => in}

object Main extends App {
  val s = in.readLine
  val t = in.readLine
  val tabale = Array.ofDim[Char](26)

  val res = s./:(true, 0){ case ((b, i), ch) => {
    val c1 = ch - 'a'
    val c2 = t(i) - 'a'
    if(b && tabale(c1) == 0 && tabale.forall(_ != t(i))) {
      tabale(c1) = t(i)
      (b,i+1)
    }
    else if(b && tabale(c1) == t(i)) (b, i+1)
    else (false, i+1)
  }}._1

  // println(tabale.mkString)
  val ans = if(res) "Yes" else "No"
  println(ans)
}