var a,b:array['A'..'Z'] of longint;
    s,ss:string;
    i,j:longint;
    c:char;
    f:boolean;
    procedure sorta;
      var i,j,k:longint;
          c:char;
          f:boolean;
          begin
            repeat
              f:=true;
              for c:='A' to 'Y' do
                if a[c]<a[chr(ord(c)+1)] then
                  begin
                     k:=a[c];
                     a[c]:=a[chr(ord(c)+1)];
                     a[chr(ord(c)+1)]:=k;
                     f:=false;
                  end;
            until f;
          end;
    procedure sortb;
      var i,j,k:longint;
          c:char;
          f:boolean;
          begin
            repeat
              f:=true;
              for c:='A' to 'Y' do
                if b[c]<b[chr(ord(c)+1)] then
                  begin
                     k:=b[c];
                     b[c]:=b[chr(ord(c)+1)];
                     b[chr(ord(c)+1)]:=k;
                     f:=false;
                  end;
            until f;
          end;
begin
  assign(input,'ancient.in');
  reset(input);
  assign(output,'ancient.out');
  rewrite(output);
  readln(s);
  readln(ss);
  for c:='A' to 'Z' do
    begin
      a[c]:=0;
      b[c]:=0;
    end;
  for i:=1 to length(s) do
    a[s[i]]:=a[s[i]]+1;
  for i:=1 to length(ss) do
    b[ss[i]]:=b[ss[i]]+1;
  sorta;
  sortb;
  f:=true;
{  for c:='A' to 'Z' do
    writeln(a[c],' ',b[c]);}
  for c:='A' to 'Z' do
    if a[c]<>b[c] then
      begin
        f:=false;
        break;
      end;
  if f then writeln('YES') else writeln('NO');
  close(input);
  close(output);
end.