fun main(args : Array<String>) {
    val S = readLine()!!.toMutableList()
    val T = readLine()!!.toMutableList()
    val length = S.size
    val start = mutableMapOf<Char, Char>()
    val goal = mutableMapOf<Char, Char>()
    (0..(length-1)).forEach {index ->
        val s = S[index]
        val t = T[index]

        if (start.contains(s) && start.get(s)!! != t || goal.contains(t) && goal.get(t)!! != s) {
            println("No")
            return
        }
        start.put(s, t)
        goal.put(t, s)
    }
    println("Yes")
}