fun main(args: Array<String>) {
    val s = readLine()!!
    val t = readLine()!!
    var sC = mutableMapOf<Char,Char>()
    var tC = mutableMapOf<Char,Char>()
    var result = "Yes"

    run loop@{
        for(i in s.indices){
            if(sC.containsKey(s[i]) && sC[s[i]] != t[i]){
                result = "No"
                return@loop
            }
            if(tC.containsKey(t[i]) && tC[t[i]] != s[i]){
                result = "No"
                return@loop
            }
            sC[s[i]] = t[i]
            tC[t[i]] = s[i]
        }
    }

    println(result)

}