program Project2;

{$APPTYPE CONSOLE}

uses
  SysUtils;

var f1:textfile;
var f2:textfile;
var a:string;
var b:string;
var ps:string;
var os:string;
var ss:string;
var i:integer;
var ii:integer;
var proverka:string;
var ccount:integer;
var ccount1:integer;
LABEL CHIQISH;
begin
os:='ABCDEFGHIJKLMNOPQRSTUVWXYZ';
SS:='BCDEFGHIJKLMNOPQRSTUVWXYZA';

assignfile(f1,'ancient.in');
assignfile(f2,'ancient.out');
reset(f1);
rewrite(f2);
readln(f1,a);
readln(f1,b);
closefile(f1);
write(f2,a,b);

for i:=1 to length(b) do
begin
        for ii:=1 to length(os) do
        begin
                //write(f2,copy(b,i,1));
                if copy(b,i,1)=copy(os,ii,1) then ps:=ps+copy(ss,ii,1);
        end;
end;
//writeln(f2,ps,b);
if ps=b then
begin
        writeln(f2,'YES');
        closefile(f2);
        GOTO CHIQISH;
end;
// Shihfrovka qilib buldik

//urinalmashganda harflar sonini tekshirib kuryapmiz.

for i:=1 to length(ps) do
        begin
                ccount:=0;
                ccount1:=0;
                for ii:=1 to length(ps) do
                begin
                 if copy(ps,i,1)=copy(ps,ii,1) then ccount:=ccount+1;
                 if copy(ps,i,1)=copy(a,ii,1) then ccount1:=ccount1+1;
                end;
                if ccount<>ccount1 then
                begin
                        writeln(f2,'NO');
                        closefile(f2);
                        goto chiqish;
                end;
        end;
writeln(f2,'YES');
closefile(f2);
CHIQISH:
  { TODO -oUser -cConsole Main : Insert code here }
end.
