program a111;

{$APPTYPE CONSOLE}

uses
  SysUtils;
type t11 = array [1..100] of longint;
var i,j:longint;
    a,b: string;
    a1,b1:t11;
procedure sor( var s:t11);
var i,j,n:longint;
    a:longint;
begin
  n:=50;
  for i:=1 to n do
    for j:=i +1 to n do
    begin
      if s[i]<s[j] then
      begin
        a:=s[i];s[i]:=s[j];s[j]:=a;
      end;
    end;
end;

begin
  { TODO -oUser -cConsole Main : Insert code here }
  assign(input,'ancient.in'); reset(input);
  assign(output,'ancient.out');rewrite(output);
  readln(a);
  readln(b);
  for i:=1 to length(a) do inc(a1[ord(a[i])-ord('A')+1]);
  for i:=1 to length(b) do inc(b1[ord(b[i])-ord('A')+1]);
  sor(a1); sor(b1);
  if length(a)<>length(b) then
  begin
    write('NO');
  end else
  begin
    j:=0;
    for i:=1 to length(a) do
    begin
       if (a1[i]<>b1[i]) then inc(j);
    end;
    if j<>0 then write('NO') else write('YES');
  end;
  close(input);
  close(output);
end.
