import std.stdio, std.string, std.range, std.conv, std.array, std.algorithm, std.math, std.typecons;

void main() {
    auto S = readln.chomp;
    auto T = readln.chomp;

    char[char] c0, c1;
    foreach (i; 0..S.length) {
        const s = S[i];
        const t = T[i];
        if (s !in c0 && t !in c1) {
            c0[s] = t;
            c1[t] = s;
        }
        if (s in c0 && c0[s] != t) {
            writeln("No");
            return;
        }
        if (t in c1 && c1[t] != s) {
            writeln("No");
            return;
        }
    }
    writeln("Yes");
}

