{$APPTYPE CONSOLE}
uses sysutils;
var s1,s2:string;
    ok:boolean;
    c1,c2:array[0..255]of longint;

procedure run;
var i,j,k:longint;
begin
  fillchar(c1,sizeof(c1),0);
  fillchar(c2,sizeof(c2),0);
  ok:=false;
  if length(s1)<>length(s2) then
    exit;
  for i:=1 to length(s1) do
    begin
      inc(c1[ord(s1[i])]);
      inc(c2[ord(s2[i])]);
    end;
  for i:=0 to 254 do
    for j:=i+1 to 255 do
      if c1[i]>c1[j] then
        begin
          k:=c1[i];
          c1[i]:=c1[j];
          c1[j]:=k;
        end;
  for i:=0 to 254 do
    for j:=i+1 to 255 do
      if c2[i]>c2[j] then
        begin
          k:=c2[i];
          c2[i]:=c2[j];
          c2[j]:=k;
        end;
  for i:=0 to 255 do
    if c1[i]<>c2[i] then
      exit;
  ok:=true;
end;

begin
  assign(input, 'ancient.in');
  reset(input);
  assign(output, 'ancient.out');
  rewrite(output);

  readln(s1);
  readln(s2);
  s1:=trim(s1);
  s2:=trim(s2);
  run;
  if ok then
    write('YES')
  else
    write('NO');

  close(input);
  close(output);
end.