program ancient;

{$APPTYPE CONSOLE}

uses
  SysUtils;

var
  f:text;
  s1,s2,l:string;
  i,j,k:integer;

  procedure read_data;
 begin
assign(f,'ancient.in');
reset(f);
readln(f,s1);
readln(f,s2);
close(f);
 end;

procedure write_data;
begin

  assign(f,'ancient.out');
  rewrite(f);
  write(f,l);
  close(f);
end;

procedure idi_na_xui;
        begin
for i:=1 to length(s1)-1 do begin
  j:=i+1;
while j<=length(s1) do
if s1[i]=s1[j] then delete(s1,j,1)
else inc(j);
            end;

for i:=1 to length(s2)-1 do
begin j:=i+1;
    while j<=length(s2) do
    if s2[i]=s2[j] then delete(s2,j,1)
    else inc(j);
       end;
        end;

begin

        read_data;
     {check length}
if length(s1)<>length(s2) then
begin l:='NO'; write_data; halt; end;
     {check length}

        idi_na_xui;

if length(s1)=length(s2) then l:='YES'
else l:='NO';

        write_data;


end.
