import scala.util.control.Breaks
object Main {
  def main(args: Array[String]) {
    var str1_check_flg:Array[Int] = Array.fill(26)(0)
    var str2_check_flg:Array[Int] = Array.fill(26)(0)
    val break = new Breaks

    val str1 = scala.io.StdIn.readLine()
    val str2 = scala.io.StdIn.readLine()
    val ascii_change = 'a'.toByte
    var check = true

    break.breakable {
      for(i <- 0 until str1.length) {
        val str1_ascii = str1(i) - ascii_change
        val str2_ascii = str2(i) - ascii_change
        
        str1_check_flg(str1_ascii) += 1
        str2_check_flg(str2_ascii) += 1
        if(!(str1_check_flg(str1_ascii) == str2_check_flg(str2_ascii))) {
          check = false
          break
        }
      }
    }

    if(check) {
      println("Yes")
    }
    else {
      println("No")
    }
  }
}