program prA;

{$APPTYPE CONSOLE}

  var s1, s2: string;
      a1, a2: array['A'..'Z'] of byte;
      b1, b2: array[0..30] of byte;


 procedure sort1;
   var i, j, t: integer;
  begin
   for i := 1 to b1[0]-1 do
    for j := i + 1 to b1[0] do
     if (b1[i] > b1[j]) then
      begin
       t := b1[i];
       b1[i] := b1[j];
       b1[j] := t;
      end;
  end;

 procedure sort2;
   var i, j, t: integer;
  begin
   for i := 1 to b2[0]-1 do
    for j := i + 1 to b2[0] do
     if (b2[i] > b2[j]) then
      begin
       t := b2[i];
       b2[i] := b2[j];
       b2[j] := t;
      end;
  end;


  procedure outno;
   begin
    writeln('NO');
    halt(0);
   end;

  var i: integer;
      c: char;

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

  readln(s1);
  readln(s2);

  fillchar(a1, sizeof(a1), 0);
  fillchar(a2, sizeof(a2), 0);

  for i:= 1 to length(s1) do inc(a1[s1[i]]);
  for i:= 1 to length(s2) do inc(a2[s2[i]]);
  b1[0] := 0;
  b2[0] := 0;
  for c:= 'A' to 'Z' do
   if a1[c] > 0 then
    begin
     inc(b1[0]);
     b1[b1[0]] := a1[c];
    end;
  for c:= 'A' to 'Z' do
   if a2[c] > 0 then
    begin
     inc(b2[0]);
     b2[b2[0]] := a2[c];
    end;
 sort1;
 sort2;
 if b1[0] <> b2[0] then outno;
 for i:= 1 to b1[0] do if b1[i] <> b2[i] then outno;
 writeln('YES');
end.

