
object Main extends App {

  import scala.io.StdIn._

  val s = readLine.trim.toCharArray
  val t = readLine.trim.toCharArray
  var count = 0.toChar
  for (i ← s.indices){
    if (s(i) >= 26) {
      for (j ← (i + 1) until s.length) {
        if (s(i) == s(j)) s(j) = count
      }
      s(i) = count
      count = (count + 1).toChar
    }
  }
  count = 0.toChar
  for (i ← t.indices){
    if (t(i) >= 26){
      for (j ← (i + 1) until t.length){
        if (t(i) == t(j)) t(j) = count
      }
      t(i) = count
      count = (count + 1).toChar
    }
  }
  println(
    if (s.zip(t).forall{case (cs, ct) ⇒ cs == ct}) "Yes"
    else "No"
  )
}
