{$o-,q+,r+}
{ $o+,q-,r-}
{$MINSTACKSIZE $00004000}
{$APPTYPE console}
uses
    sysutils;
type
    int = longint;
const
    finname = 'ancient';
var
s1, s2: string;
c1, c2: array['A' .. 'Z'] of int;
i: int;
ch, ch1: char;
begin
    reset(input, finname + '.in');
    rewrite(output, finname + '.out');

    readln(s1);
    readln(s2);

    fillchar(c1, sizeof(c1), 0);
    fillchar(c2, sizeof(c2), 0);
    for i := 1 to length(s1) do
        inc(c1[s1[i]]);
    for i := 1 to length(s2) do
        inc(c2[s2[i]]);

    for ch1 := 'A' to 'Z' do
        for ch := succ(ch1) to 'Y' do
            if (c1[ch] > c1[succ(ch)]) then begin
                i := c1[ch];
                c1[ch] := c1[succ(ch)];
                c1[succ(ch)] := i;
            end;
    for ch1 := 'A' to 'Z' do
        for ch := succ(ch1) to 'Y' do
            if (c2[ch] > c2[succ(ch)]) then begin
                i := c2[ch];
                c2[ch] := c2[succ(ch)];
                c2[succ(ch)] := i;
            end;

    for ch := 'A' to 'Z' do
        if (c1[ch] <> c2[ch]) then begin
            write('NO');
            exit;
        end;
    write('YES');
end.