program Project2;

{$APPTYPE CONSOLE}
var
 s1,s2:string;
 Cyc1, Cyc2 : Integer;
 fl1,res:boolean;
 d1,d2:array[0..256] of integer;
 c:integer;
begin
  Assign(Input, 'ancient.in');
  Reset(Input);
  Assign(Output, 'ancient.out');
  Rewrite(Output);
  readln(s1);
  readln(s2);
  res:=(length(s1)=length(s2));
  for cyc1:=1 to 256 do
	begin
	  d1[cyc1]:=0;
	  d2[cyc1]:=0;
	end;
  for cyc1:=1 to length(s1) do
	begin
	  inc(d1[ord(s1[cyc1])]);
	  inc(d2[ord(s2[cyc1])]);
	end;
  for cyc1:=256 downto 2 do
	for cyc2:=2 to cyc1 do
	  if d1[cyc2-1]>d1[cyc2] then
		begin
		  c:=d1[cyc2];
		  d1[cyc2]:=d1[cyc2-1];
		  d1[cyc2-1]:=c;
		end;
  for cyc1:=256 downto 2 do
	for cyc2:=2 to cyc1 do
	  if d2[cyc2-1]>d2[cyc2] then
		begin
		  c:=d2[cyc2];
		  d2[cyc2]:=d2[cyc2-1];
		  d2[cyc2-1]:=c;
		end;
  fl1:=true;
  for cyc1:=1 to 256 do
	fl1:=fl1 and (d1[cyc1]=d2[cyc1]);
  res:=res and fl1;
  if res then writeln('YES')
  else writeln('NO');
  Close(Input);
  Close(Output);
end.
