{.$define debug}

{$apptype console}

{$ifdef debug}
{$R+,S+,Q+,I+,O-}
{$else}
{$R+,S-,Q+,I+,O+}
{$endif}

{$assertions on}
{$apptype console}

program template;
uses
 SysUtils;
const
 alphamax = 26;
 {$ifdef debug}
 cinfile = 'input.txt';
 coutfile = 'output.txt';
 {$else}
 cinfile = 'ancient.in';
 coutfile = 'ancient.out';
 {$endif}
type
 int = longint;
 real = extended;
 tArray = array [0..alphamax] of int;
var
 n :int;
 a,b :tArray;
 ans :boolean;

procedure init;
begin
 fillchar (n,integer(@ans) - integer(@n),0);
 ans := true;
end;

procedure readdata;
var i,j :int;
    s :string;
begin
 assign (input,cinfile);
 reset (input);
 readln (s);
 s := trim(s);
 for i := 1 to length(s) do
  inc (a[ord(s[i]) - ord('A')]);
 readln (s);
 s := trim(s);
 for i := 1 to length(s) do
  inc (b[ord(s[i]) - ord('A')]);
 close (input);
end;

procedure outdata;
var i,j :int;
begin
 assign (output,coutfile);
 rewrite (output);
 if ans then
  writeln ('YES')
 else
  writeln ('NO');
 close (output);
end;

procedure swap (var a,b :int);
begin
 a := a xor b;
 b := a xor b;
 a := a xor b;
end;

procedure sort (var a :tArray);
var i,j :int;
begin
 for i := 0 to alphamax-2 do
  for j := i+1 to alphamax-1 do
   if a[i] > a[j] then
    swap (a[i],a[j]);
end;

procedure solve;
var i,j :int;
begin
 sort (a);
 sort (b);
 for i := 0 to alphamax-1 do
  if a[i] <> b[i] then
   begin
    ans := false;
    exit;
   end;
end;

begin
 init;
 readdata;
 solve;
 outdata;
end.
