{$APPTYPE CONSOLE}

var a,b:array['A'..'Z']of integer;

procedure init;
 var s:string;i:integer;
  begin
   assign(input,'ancient.in');reset(input);
    readln(s);
     for i:=1 to length(s) do
      inc(a[s[i]]);
    readln(s);
     for i:=1 to length(s) do
      inc(b[s[i]]);
    close(input);
 end;
procedure sort;
 var i,j:char; k:integer;
  begin
   for i:='A' to 'Y' do
    for j:=chr(ord(i)+1) to 'Z' do
     if a[i]>a[j] then begin
      k:=a[i];a[i]:=a[j];a[j]:=k;end;
for i:='A' to 'Y' do
    for j:=chr(ord(i)+1) to 'Z' do
     if b[i]>b[j] then begin
      k:=b[i];b[i]:=b[j];b[j]:=k;end;
end;
function day:string;
 var
   t:boolean;
   i:integer;c:char;

    begin
     t:=true;
      sort;
   for c:='A' to 'Z' do
    if a[c]<>b[c] then t:=false;
  if t then day:='YES' else day:='NO';

 end;

procedure done;
 begin
  assign(output,'ancient.out');
   rewrite(output);

    write(day);
    close(output);
 end;

begin
init;
 done;


end.
 