fun main(args: Array<String>) {
    val S = readInputLine().toCharArray()
    val T = readInputLine().toCharArray()

    val R1 = mutableMapOf<Char, Char>()
    val R2 = mutableMapOf<Char, Char>()

    for ((i, c) in S.withIndex()) {
        val r1 = R1.get(c) ?: '-'
        val r2 = R2.get(T[i]) ?: '-'
        
        if (r1 == '-') {
            R1.put(c, T[i])
        } else {
            if (r1 != T[i]) {
                println("No")
                return
            }
        }
        
        if (r2 == '-') {
            R2.put(T[i], c)
        } else {
            if (r2 != c) {
                println("No")
                return
            }
        }
    }

    println("Yes")
}

fun readInputLine(): String {
    return readLine()!!
}
