fun main(args : Array<String>) {
    val s = readLine()!!
    val t = readLine()!!

    val sd = mutableMapOf<Char, Int>()
    val td = mutableMapOf<Char, Int>()

    var dummy = 0

    for (i in s.indices) {
        val si = sd[s[i]] ?: dummy
        val ti = td[t[i]] ?: dummy

        if (si != ti) {
            println("No")
            return
        }

        sd[s[i]] = si
        td[t[i]] = ti
        dummy++
    }

    println("Yes")
}