fun main(args: Array<String>) {
    val S = readLine()!!
    val T = readLine()!!
    val dic0 = mutableSetOf<Char>()
    var cnt = 0
    for (c in 0 until 26) {
        val dic = mutableSetOf<Char>()
        for (i in 0 until S.length) {
            if (T[i] == 'a'+c) {
                dic.add(S[i])
                dic0.add(S[i])
            }
        }
        if (dic.size > 1) {
            println("No")
            return
        }
        if (dic.size == 1) cnt++
    }
    if (dic0.size == cnt) println("Yes")
    else println("No")
}