import java.util.*
import kotlin.collections.ArrayDeque
import kotlin.collections.HashMap

fun main(args: Array<String>){

//    var (H, W) = readLine()!!.split(" ").map{it.toInt()}
    var S = readLine()!!.toCharArray()
    var T = readLine()!!.toCharArray()
    var ans = "Yes"
    var transMapS = HashMap<Char,Char>()
    var transMapT = HashMap<Char,Char>()

    for(i in S.indices){
        if(transMapS.containsKey(S[i])){
            if(transMapS.get(S[i]) != T[i]){
                ans = "No"
                break
            }
        } else {
            transMapS.set(S[i],T[i])
        }

    }

    for(i in T.indices){
        if(transMapT.containsKey(T[i])){
            if(transMapT.get(T[i]) != S[i]){
                ans = "No"
                break
            }
        } else {
            transMapT.set(T[i],S[i])
        }

    }
    println(ans)




}