fun main(arr:Array<String>) {
    val s = readLine()!!
    val t = readLine()!!
    if(isSame(s,t)) {
        println("Yes")
    } else {
        println("No")
    }
}

fun isSame(s:String, t:String):Boolean {
    val map1 = getMap(s)
    val map2 = getMap(t)
    for(key in map1.keys) {
        if(!map2.containsKey(key)) {
            return false
        }
        val list1 = map1[key]!!
        val list2 = map2[key]!!
        if(list1.size != list2.size) {
            return false
        }
        for(idx in list1.indices) {
            if(list1[idx] != list2[idx]) {
                return false
            }
        }
    }
    return true
}

fun getMap(s:String):MutableMap<Int,MutableList<Int>> {
    val charMap = mutableMapOf<Char,Int>()
    val ret = mutableMapOf<Int, MutableList<Int>>()
    for(i in s.indices) {
        if(!charMap.containsKey(s[i])) {
            charMap[s[i]] = i
            ret[i] = mutableListOf()
        }
        val idx = charMap[s[i]]!!
        ret[idx]!!.add(i)
    }
    return ret
}