program ProbA;

{$APPTYPE CONSOLE}
var
  s1, s2: string;
  ch,sh:char;
  i : longint;
  f : boolean;
 df, dg : array['A'..'Z']of longint;
begin
  assign(input, 'ancient.in');
  reset(input);
  assign(output, 'ancient.out');
  rewrite(output);
  readln(S1);
  readln(s2);
  fillchar(df,sizeof(df),0);
  fillchar(dg,sizeof(dg),0);
  for i:=1 to length(s1)do inc(df[s1[i]]);
  for i:=1 to length(s2)do inc(dg[s2[i]]);
  for ch := 'A' to 'Z' do if df[ch] > 0 then begin
      for sh := 'A' to 'Z' do
      if dg[sh] = df[ch] then begin
          dg[sh] := 0;
          break;
      end;
     df[ch] := 0;
  end;
  f:=true;
  for ch:='A' to 'Z' do
  if df[ch] + dg[ch] > 0 then begin
    f:=false;
    break;
  end;
  if f and(length(s1)=length(s2))then writeln('YES')
  else writeln('NO');
  close(input);
  close(output);
end.
 