import scala.io.{StdIn => in}

object Main extends App {
  val s = in.readLine
  val t = in.readLine

  val n = 'z'-'a' + 1
  val ts = Array.fill(n)(-1)
  val tt = Array.fill(n)(-1)

  val isPosi = (0 until s.size).forall(i => {
    val a = s(i) - 'a'
    val b = t(i) - 'a'
    if(ts(a) != -1 || tt(b) != -1) {
      if(ts(a) != b || tt(b) != a) false
      else true
    }
    else {
      ts(a) = b
      tt(b) = a
      true
    }
  })

  val ans = if(isPosi) "Yes" else "No"
  println(ans)
}