program a_;

{$APPTYPE CONSOLE}
type
  Tarray= array ['A'..'Z'] of integer;
var
  first,second:string;
  a,b : tARRAY;
  i:integer;

procedure sort(var c: Tarray);
var
  t,h:char;
  g:integer;
begin
 for h:='A' to 'Z' do
  for t:=h to 'Y' do
    begin
      if c[t]>c[chr(ord(t)+1)] then
        begin
          g:=c[t];
          c[t]:=c[t+1];
          c[t+1]:=g;
        end;
    end;
end;

function equal(a,b: Tarray):boolean;
var
  c:char;
begin
  equal:=true;
  for c:='A' to 'Z' do
    if a[c]<>b[c] then
      begin
        equal:=false;
        exit;
      end;
end;

begin
  { TODO -oUser -cConsole Main : Insert code here }
  assign(input,'ancient.in');
  assign(output,'ancient.out');
  readln(first);
  readln(second);
  fillchar(a,sizeof(a),0);
  fillchar(b,sizeof(b),0);
  for i:=1 to length(first) do
    begin
      inc(a[first[i]]);
    end;
  for i:=1 to length(second) do
    begin
      inc(b[second[i]]);
    end;
  sort(a);
  sort(b);
  if equal(a,b) then
    writeln('YES') else
      writeln('NO');


end.
