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

T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;

bool calc(string s, string t) {
    int[] freq(string s) {
        int[char] d;
        foreach (c; s) d[c]++;
        auto v = d.values;
        v.sort();
        return v;
    }

    return freq(s) == freq(t);
}

void main() {
    auto s = read!string;
    auto t = read!string;
    writeln(calc(s, t) ? "Yes" : "No");
}
