{$DEFINE DMI}
{$DEFINE DO0}
{$DEFINE DEBUG}
{$IFDEF DEBUG}
{$B-,I+,N+,O-,Q+,R+,S+}
{$ELSE}
{$B-,I-,N+,O+,Q-,R-,S-}
{$ENDIF}
{$APPTYPE CONSOLE}
Program OlympSol;
uses SysUtils;
const TaskName = 'ancient';
 MaxN = 102; MaxK = 256;
var i, j, k, l, m, n: Integer;
 a, b: array [0..MaxK] of Integer;
 ok: Boolean;
 s: String;

BEGIN
 assign (input, TaskName + '.in'); reset (input);
 assign (output, TaskName + '.out'); rewrite (output);
{$IFDEF DMI} repeat {$ENDIF}
 fillchar (a, sizeof (a), 0);
 fillchar (b, sizeof (b), 0);
 readln (s);
 n := Length (s);
 for i := 1 to n do inc (a[ord (s[i])]);
 for i := 1 to MaxK - 1 do
  for j := i + 1 to MaxK do
   if a[i] > a[j] then begin
    k := a[i]; a[i] := a[j]; a[j] := k;
   end;
 readln (s);
 n := Length (s);
 for i := 1 to n do inc (b[ord (s[i])]);
 for i := 1 to MaxK - 1 do
  for j := i + 1 to MaxK do
   if b[i] > b[j] then begin
    k := b[i]; b[i] := b[j]; b[j] := k;
   end;
 ok := True;
 for i := 1 to MaxK do
  if a[i] <> b[i] then begin
   ok := False;
   break;
  end;
 if ok then writeln ('YES') else writeln ('NO');
{$IFDEF DMI} until seekeof; {$ENDIF}
END.
