import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val s = sc.next()
    val t = sc.next()
    val transST = Array(26) { -1 }
    val transTS = Array(26) { -1 }

    for (i in s.indices) {
        val chS = s[i] - 'a'
        val chT = t[i] - 'a'
        if (transST[chS] == -1) {
            if (transTS[chT] == -1) {
                transST[chS] = chT
                transTS[chT] = chS
            } else if (transTS[chT] != chS) {
                println("No")
                return
            }
        } else if (transST[chS] != chT) {
            println("No")
            return
        }
    }
    println("Yes")
}
