program taskA;

{$APPTYPE CONSOLE}

var a,b : array [1..26] of integer;
  i,j,t:integer;
  good:boolean;
  f:textfile;
  str1,str2:string;

begin
  AssignFile(f,'ancient.in'); Reset(f);
  readln(f,str1);
  readln(f,str2);

  for i:=1 to length (str1) do
    begin
    inc(a[ord(str1[i])-ord('A')+1]);
    inc(b[ord(str2[i])-ord('A')+1]);
    end;

  for i:=1 to 26 do
    for j:=i+1 to 26 do
      if a[i]>a[j] then
        begin
        t:=a[i];
        a[i]:=a[j];
        a[j]:=t;
        end;

  for i:=1 to 26 do
    for j:=i+1 to 26 do
      if b[i]>b[j] then
        begin
        t:=b[i];
        b[i]:=b[j];
        b[j]:=t;
        end;


  good:=true;
  for i:=1 to 26 do
    good:=good and (b[i]=a[i]);

  CloseFile(f);
  AssignFile(f,'ancient.out');
  Rewrite(f);
  if good then
    writeln(f,'YES')
  else
    writeln(f,'NO');
  CloseFile(f);

end.
