program ACipher;

{$APPTYPE CONSOLE}

var
 i,k,j,l,m,n:integer;
 s1,s2:string;
 oc1,oc2:array[0..100] of byte;
 label ex;


begin
 assign(input,'ancient.in');
 assign(output,'ancient.out');
 reset(input);
 rewrite(output);
 readln(s1);
 readln(s2);

 fillchar(oc1,sizeof(oc1),0);
 fillchar(oc2,sizeof(oc2),0);

 l:=length(s1);
 for i:=1 to l do
  begin
   if s1[i] in ['A'..'Z'] then
    begin
     m:=1;
     for k:=i+1 to l do
      begin
       if s1[k]=s1[i] then
        begin
         inc(m);
         s1[k]:='.';
        end;
      end;
     inc(oc1[0]);
     oc1[oc1[0]]:=m;
    end;
  end;

 l:=length(s2);
 for i:=1 to l do
  begin
   if s2[i] in ['A'..'Z'] then
    begin
     m:=1;
     for k:=i+1 to l do
      begin
       if s2[k]=s2[i] then
        begin
         inc(m);
         s2[k]:='.';
        end;
      end;
     inc(oc2[0]);
     oc2[oc2[0]]:=m;
    end;
  end;

  for i:=2 to oc1[0] do
   for k:=i downto 2 do
    begin
     if oc1[k]<=oc1[k-1] then
      begin
       m:=oc1[k];
       oc1[k]:=oc1[k-1];
       oc1[k-1]:=m;
      end;
    end;


  for i:=2 to oc2[0] do
   for k:=i downto 2 do
    begin
     if oc2[k]<=oc2[k-1] then
      begin
       m:=oc2[k];
       oc2[k]:=oc2[k-1];
       oc2[k-1]:=m;
      end;
    end;

{ for i:=1 to oc1[0] do
  write(oc1[i],' ');
  writeln;

 for i:=1 to oc2[0] do
  write(oc2[i],' ');
  writeln;}

 if oc1[0]<>oc2[0] then
  begin
   writeln('NO');
   goto ex;
  end;

  for i:=1 to oc1[0] do
   if oc1[i]<>oc2[i] then
    begin
     writeln('NO');
     goto ex;
    end;

  writeln('YES');
ex:
 close(input);
 close(output);
end.

