const
      inp='ancient.in';
      outt='ancient.out';

 var
     a,b:array ['A'..'Z'] of integer;
     d,f:ARray[1..28] of longint;
     s1,s2:string;
     ok:boolean;

procedure readdata;
 var
     i:integer;
begin
   assign(input,inp);
    reset(input);
       readln(s1);
       readln(s2);
   close(input);
end;

procedure get_aaa;
var
    i,j,c: integer;

begin
  for i:=1 to 28 do
  for j:=I+1 to 28 do
   if d[i]<d[j]  then
    begin
     c:=d[i];
     d[i]:=d[j];
     d[j]:=c;
    end;

 for i:=1 to 28 do
  for j:=i+1 to 28 do
   if f[i]<f[j]  then
    begin
     c:=f[i];
     f[i]:=f[j];
     f[j]:=c;
    end;

end;

procedure solve;
 var
      i,j:char;
      c,P:longint;

begin
 ok:=false;
 for i:='A' to 'Z' do
  begin
   a[i]:=0; b[i]:=0;
  end;
 if length(s1)<>length(s2) then exit;
 for c:=1 to length(s1) do
  begin
    inc(a[s1[c]]);
    inc(b[s2[c]]);
  end;
 p:=0;
 for i:='A' to  'Z' do
  begin
   inc(p);
   d[p]:=a[i];
   f[p]:=b[i];
  end;
 get_aaa;
 FOR C:=1 TO 28 DO
  IF D[C]<>F[C] THEN EXIT;

 ok:=true;
end;

procedure writedata;

begin
  assigN(output,outt);
   rewrite(output);
    IF OK THEN  writeln('YES')
          ELSE writeln('NO');
  closE(output);
end;

begin
  readdata;
   solve;
  writedata;
end.
