
{$APPTYPE CONSOLE}

var wor1,wor2:string;
    i,i1,i2,j,k1,k2,n,sasa1,sasa2:integer;
    tek1,tek2:char;

    sym1,sym2:array of integer;

begin
  assignfile(input,'ancient.in');
  assignfile(output,'ancient.out');
  reset(input);
  rewrite(output);

  readln(wor1);
  readln(wor2);

  if length(wor1)<>length(wor2) then
  begin
    write('NO');
    exit;
  end;

  n:=length(wor1);
  setlength(sym1,n);
  setlength(sym2,n);

  i1:=1;
  i2:=1;

  k1:=0;
  k2:=0;

  repeat
    tek1:=wor1[1];
    tek2:=wor2[1];
    for j:=1 to length(wor1) do
    begin
    if wor1[j]=tek1 then
      begin
      sym1[k1]:=sym1[k1]+1;
      delete(wor1,j,1);
      end;
    if wor2[j]=tek2 then
      begin
      sym2[k2]:=sym2[k2]+1;
      delete(wor2,j,1);
      end;
    end;

  inc(i1);
  inc(i2);
  inc(k1);
  inc(k2);
  until wor1='';

for i:=0 to n-1 do
begin
  for j:=0 to n-1 do
  begin
    if sym1[i]=sym2[j] then
    begin
    sym1[i]:=-1;
    sym2[j]:=-1;
    break;
    end;
  end;
end;

for i:=0 to n-1 do
begin
  if sym1[i]=-1 then inc(sasa1) else dec(sasa1,1000);
  if sym2[i]=-1 then inc(sasa2) else dec(sasa2,1000);
end;

if sasa1>0 then write('YES') else write('NO');

end.
 