import java.util.*

fun main(args: Array<String>) {
    val S = readLine()!!
    val T = readLine()!!

    val uf = UnionFind(52)
    val sts = TreeSet<Char>(S.toList())
    val stt = TreeSet<Char>(T.toList())

    for (i in S.indices) {
        uf.unite((S[i] - 'a').toLong(), T[i] - 'a' + 26L)
    }

    var f = true

    for (i in 0..25L) for (j in i + 1 .. 25L) {
        f = f && !uf.same(i + 26, j + 26)
        f = f && !uf.same(i, j)
    }

    if (f) {
        println("Yes")
    } else {
        println("No")
    }
}

/**
 * A disjoint set data structure with path compression and union by size.
 *
 * Each element is represented by an index (0-indexed).
 */
class UnionFind(n: Long) {
    val size = n.toInt()

    private val parent: Array<Long>
    private val cardinality: Array<Long>

    init {
        parent = Array(size) { -1L }
        cardinality = Array(size) { 1L }
    }

    /**
     * Find a root element of a set `x` belongs to.
     */
    fun find(x: Long): Long {
        return if (parent[x.toInt()] == -1L) {
            x
        } else {
            parent[x.toInt()] = find(parent[x.toInt()])
            parent[x.toInt()]
        }
    }

    /**
     * Unite sets contain two elements `x` and `y`.
     * If `x` and `y` already belong to a same set, nothing happens.
     *
     * @return If `x` and `y` belong to a same set, return false.
     */
    fun unite(x: Long, y: Long): Boolean {
        val u = find(x).toInt()
        val v = find(y).toInt()
        if (u == v) {
            return false
        }

        val newSize = cardinality[v] + cardinality[u]

        if (cardinality[u] < cardinality[v]) {
            parent[u] = v.toLong()
            cardinality[v] = newSize
        } else {
            parent[v] = u.toLong()
            cardinality[u] = newSize
        }

        return true
    }

    /**
     * Check whether `x` and `y` belongs to a same set.
     *
     * @return `true` if `x` and `y` are in a same set.
     */
    fun same(x: Long, y: Long): Boolean {
        return find(x) == find(y)
    }

    /**
     * Get a size of a set `x` belongs to.
     */
    fun getCardinalityOf(x: Long): Long {
        return cardinality[find(x).toInt()]
    }
}
