program Project1;

{$APPTYPE CONSOLE}

uses
  SysUtils;

var s1, s2: String;
    mas1, mas2: array[1..26] of Integer;
    i, j, tmp: Integer;

    fin: Boolean;


begin

  AssignFile(Input, 'ancient.in');
  Reset(Input);
  AssignFile(Output, 'ancient.out');
  Rewrite(Output);

  Readln(s1);
  Readln(s2);

  FillChar(mas1, sizeof(mas1), 0);
  FillChar(mas2, sizeof(mas2), 0);

  for i := 1 to length(s1) do
    Inc(mas1[ord(s1[i])-ord('A')+1]);

  for i := 1 to length(s2) do
    Inc(mas2[ord(s2[i])-ord('A')+1]);


  for i := 1 to 25 do
    for j := 26 downto i+1 do
      if mas1[j] < mas1[j-1] then
      begin
        tmp := mas1[j];
        mas1[j] := mas1[j-1];
        mas1[j-1] := tmp;
      end;

  for i := 1 to 25 do
    for j := 26 downto i+1 do
      if mas2[j] < mas2[j-1] then
      begin
        tmp := mas2[j];
        mas2[j] := mas2[j-1];
        mas2[j-1] := tmp;
      end;


  fin := True;

  for i := 1 to 26 do
    if mas1[i] <> mas2[i] then
    begin
      fin := False;
      Break;
    end;

  if fin then Writeln('YES')
         else Writeln('NO');


  CloseFile(Input);
  CloseFile(Output);
end.

