program za;

{$APPTYPE CONSOLE}

uses
  SysUtils;

var
  s1,s2:string[127];
  a1,a2:array[0..255] of integer;
  i,j,k,n:integer;
begin
  assign(input,'ancient.in');
  reset(input);
  assign(output,'ancient.out');
  rewrite(output);
  readln(s1);
  readln(s2);
  n := length(s1);
  fillchar(a1,sizeof(a1),0);
  fillchar(a2,sizeof(a2),0);
  for i := 1 to n do inc(a1[ord(s1[i])]);
  for i := 1 to n do inc(a2[ord(s2[i])]);
  for i := 0 to 254 do
    for j := 255 downto i+1 do
      if a1[j]>a1[j-1] then
        begin
          k := a1[j];
          a1[j] := a1[j-1];
          a1[j-1] := k;
        end;
  for i := 0 to 254 do
    for j := 255 downto i+1 do
      if a2[j]>a2[j-1] then
        begin
          k := a2[j];
          a2[j] := a2[j-1];
          a2[j-1] := k;
        end;
  for i := 0 to 255 do
    if a1[i]<>a2[i] then
      begin writeln('NO'); halt; end;
  writeln('YES');
end.
 