program ancient;

{$APPTYPE CONSOLE}

var
	a, b		: array [0..25] of integer;
   i, j, n	: integer;
   Ch			: char;

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

   for i := 0 to 25 do begin
   	a[i] := 0;
      b[i] := 0;
   end;
   while not eoln do begin
   	read(Ch);
      if Ch in ['A'..'Z'] then
	      a[ord(Ch) - ord('A')] := a[ord(Ch) - ord('A')] + 1;
   end;
   readln;
   while not eoln do begin
   	read(Ch);
      if Ch in ['A'..'Z'] then
	      b[ord(Ch) - ord('A')] := b[ord(Ch) - ord('A')] + 1;
   end;

   for i := 0 to 24 do
   	for j := i + 1 to 25 do
			if a[i] < a[j] then begin
         	n := a[i];
            a[i] := a[j];
            a[j] := n;
         end;
   for i := 0 to 24 do
   	for j := i + 1 to 25 do
			if b[i] < b[j] then begin
         	n := b[i];
            b[i] := b[j];
            b[j] := n;
         end;
   for i := 0 to 25 do
   	if a[i] <> b[i] then begin
      	writeln('NO');
         halt;
      end;
   writeln('YES');
end.
