program Project1;
{$APPTYPE CONSOLE}
Const
  cIN  = 'ancient';
  cOUT = 'ancient';

Var
  sIN1, sIN2: string;
  alf1,alf2:array [0..32] of integer;
  alb1,alb2:array [0..100] of integer;
  a:integer;
  ifis:boolean;

begin
  AssignFile(Input, cIN + '.in');
  Reset(Input);
  AssignFile(Output, cOUT + '.out');
  Rewrite(Output);

  Readln(sIN1);
  Readln(sIN2);

  fillchar(alf1,sizeof(alf1),0);
  fillchar(alf2,sizeof(alf2),0);
  fillchar(alb1,sizeof(alb1),0);
  fillchar(alb2,sizeof(alb2),0);

  for a:=1 to length(sIN1) do inc(alf1[byte(sIN1[a])-byte('A')]);
  for a:=1 to length(sIN2) do inc(alf2[byte(sIN2[a])-byte('A')]);

  for a:=0 to 32 do inc(alb1[alf1[a]]);
  for a:=0 to 32 do inc(alb2[alf2[a]]);

  ifis:=true;
  for a:=0 to 100 do if alb1[a]<>alb2[a] then ifis:=false;

  if ifis then writeln('YES') else writeln('NO');

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