fun main(args: Array<String>) {
    abc110c()
}

fun abc110c() {
    val s = readLine()!!
    val t = readLine()!!

    val sMap = mutableMapOf<Char, Char>()
    val tMap = mutableMapOf<Char, Char>()
    for (i in s.indices) {
        val sc = s[i]
        val tc = t[i]
        sMap[sc]?.let { if (it != tc) return println("No") }
        tMap[tc]?.let { if (it != sc) return println("No") }
        sMap[sc] = tc
        tMap[tc] = sc
    }

    return println("Yes")
}
