"use strict";
function Main(input) {
    let lines = input.split("\n");
    let s = lines[0];
    let t = lines[1];
// console.log(`len: ${s.length}`);
    const a = 'a'.charCodeAt(0);
    let sa = new Array(26).fill(0);
    let ta = new Array(26).fill(0);
    let result = false;
    for (let n = 0; n < s.length; n++) {
        if (sa[s.charCodeAt(n) - a] == 0) sa[s.charCodeAt(n) - a] = t.charCodeAt(n) - a;
        else if (sa[s.charCodeAt(n) - a] != t.charCodeAt(n) - a) {
            console.log('No');
            return;
        }
        if (ta[t.charCodeAt(n) - a] == 0) ta[t.charCodeAt(n) - a] = s.charCodeAt(n) - a;
        else if (ta[t.charCodeAt(n) - a] != s.charCodeAt(n) - a) {
            console.log('No');
            return;
        }
    }
    console.log('Yes');
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));
