{$A+,B-,C+,D+,E-,F-,G+,H+,I+,J-,K-,L+,M-,N+,O+,P+,Q-,R-,S-,T-,U-,V+,W-,X+,Y+,Z1}
{$MINSTACKSIZE $00004000}
{$MAXSTACKSIZE $00100000}
{$IMAGEBASE $00400000}
{$APPTYPE GUI}
program z1;

{$APPTYPE CONSOLE}

uses
  SysUtils;
  var n,ii,jj:integer;
a, b : array[0..256] of integer;
    f : boolean;
    t, len: integer;
    c: char;
    s1, s2 : string;

procedure init;
 begin
  assign(input,'ancient.in');
  assign(output,'ancient.out');
  reset(input);
  rewrite(output);
//  fillchar(a, sizeof(a), 0);
//  fillchar(b, sizeof(b), 0);
  len := 0;
  readln(s1);
  readln(s2);
  for ii := 1 to length(s1) do
   begin
    inc(a[ord(s1[ii])]);
    inc(b[ord(s2[ii])]);

   end;
 end;

procedure qsorta(l, r : integer);
var i, j, m : integer;
 begin
  i := l;
  j := r;
  m := a[(i+j)div 2];
  repeat
   while a[i]>m do inc(i);
   while a[j]<m do dec(j);
   if i<=j then
    begin
     t := a[i];
     a[i] := a[j];
     a[j] := t;
     inc(i);
     dec(j);
    end;
  until i>j;
  if (j > l)  then qsorta(l,j);
  if (i < r)  then qsorta(i,r);

 end;
procedure qsortb(l, r : integer);
var i, j, m : integer;
 begin
  i := l;
  j := r;
  m := a[(i+j)div 2];
  repeat
   while b[i]>m do inc(i);
   while b[j]<m do dec(j);
   if i<=j then
    begin
     t := b[i];
     b[i] := b[j];
     b[j] := t;
     inc(i);
     dec(j);
    end;
  until i>j;
  if (j > l)  then qsortb(l,j);
  if (i < r)  then qsortb(i,r);

 end;
procedure puza;
var n, i, j : integer;
 begin
  n := 256;
  for i := 0 to n-1 do
   for j := 0 to i do
    begin
     if a[j]< a[j+1]then
      begin
         t := a[j];
         a[j] := a[j+1];
         a[j+1] := t;
      end;
    end;
 end;
procedure puzb;
var n, i, j : integer;
 begin
  n := 256;
  for i := 0 to n-1 do
   for j := 0 to i do
    begin
     if b[j]< b[j+1]then
      begin
         t := b[j];
         b[j] := b[j+1];
         b[j+1] := t;
      end;
    end;
 end;
procedure solve;
 begin
//  qsorta(0,256);
//  qsortb(0,256);
  puza;
  puzb;
  f := true;
  ii := 0;
  while (ii<=256) and f do
   begin
   if (a[ii]<>b[ii]) then f := false;
    inc(ii);
   end;
  if f then write('YES') else write('NO');

 end;

procedure final;
 begin
  close(input);
  close(output);
 end;

begin
init;
solve;
final;
end.
