PROGRAM ASD;
Const InFile='ancient.in';
        OutFile='ancient.out';
var a,b                                   : array['A'..'Z'] of integer;
    i,j,k,l,n,m                         : integer;
    S,S1                                : STRING;
        ok                                      : boolean;
        i1,j1           : char;
{-------------------------------------------}
PROCEDURE VVOD;
BEGIN
 Assign(input,infile);
 Reset(input);
  READLN(S);
  READLN(S1);
  N:=LENGTH(S);
 Close(input);
END;
{-------------------------------------------}
PROCEDURE OCNOV;
var i : integer;
BEGIN
 fillchar(a,sizeof(a),0);
 fillchar(b,sizeof(b),0);
 for i:=1 to n do
  begin
   inc(a[s[i]]);
   inc(b[s1[i]]);
  end;
 for i1:='A' to 'Z' do
  if a[i1]>0 then
  begin
   for j1:='A' to 'Z' do
    if a[i1]=b[j1] then
     begin
      b[j1]:=0;
      A[I1]:=0;
      break;
     end;
  end;
 ok:=true;
 for i1:='A' to 'Z' do
  if (a[i1]>0)or(b[i1]>0) then
   begin
    ok:=false;
    break;
   end;
END;
{-------------------------------------------}
PROCEDURE VIVOD;
BEGIN
 Assign(output,outfile);
 Rewrite(output);
  if ok then write('YES') else write('NO');
 Close(output);
END;
{-------------------------------------------}
BEGIN
 VVOD;
 OCNOV;
 VIVOD;
END.