import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val s = sc.next()
    val t = sc.next()
    println(problem110c(s, t))
}

fun problem110c(s: String, t: String): String {
    var ok = true
    val ma = mutableMapOf<Char, Char>()
    val ima = mutableMapOf<Char, Char>()
    for (i in 0 until s.length) {
        val si = s[i]
        val ti = t[i]
        if (ma.containsKey(si) && ma[si] != ti) ok = false
        if (ima.containsKey(ti) && ima[ti] != si) ok = false
        ma[si] = ti
        ima[ti] = si
    }
    return if (ok) "Yes" else "No"
}