{$APPTYPE CONSOLE}


const
    _fin='ANCIENT.IN';
    _fout='ANCIENT.OUT';
var
    a,b:array[0..255] of byte;
    s1,s2:string;
    res:boolean;
procedure process;
var i,j:longint;
    t:byte;
begin
    fillchar(a,sizeof(a),0);
    fillchar(b,sizeof(b),0);
    for i:=1 to length(s1) do
        inc(a[ord(s1[i])]);
    for i:=1 to length(s2) do
        inc(b[ord(s2[i])]);
    for i:=0 to 254 do
        for j:=i+1 to 255 do
            if a[i]<a[j] then begin
                t:=a[i];a[i]:=a[j];a[j]:=t;
            end; 
    for i:=0 to 254 do
        for j:=i+1 to 255 do
            if b[i]<b[j] then begin
                t:=b[i];b[i]:=b[j];b[j]:=t;
            end;
    for i:=0 to 255 do
        if a[i]<>b[i] then
        begin
            res:=false;exit;
        end;
    res:=true;
end;
begin
    assign(input,_fin);reset(input);
    readln(s1);
    while s1[1]=' ' do delete(s1,1,1);
    while s1[length(s1)]=' ' do delete(s1,length(s1),1);
    readln(s2);
    while s2[1]=' ' do delete(s2,1,1);
    while s2[length(s2)]=' ' do delete(s2,length(s2),1);
    close(input);
    res:=false;
    process;
    assign(output,_fout);rewrite(output);
    if res then writeln('YES') else writeln('NO');
    close(output);
end.