program za;

{$APPTYPE CONSOLE}

uses
  SysUtils;

var s1, s2 : string;
    a : array ['A'..'Z'] of integer;
    b : array ['A'..'Z'] of integer;
    res : boolean;
    i,n : integer;

procedure init;
begin
  assign(input,'ancient.in');
  reset(input);
  readln(s1);
  readln(s2);
  close(input);
end;

procedure solve;
 var ch,c1,c2 : char;
     t : integer;
begin
  res := false;
  fillchar(a,sizeof(a),0);
  fillchar(b,sizeof(b),0);
  n := length(s1);
  for i := 1 to n do inc(a[s1[i]]);
  for i := 1 to n do inc(b[s2[i]]);
  for c1 := 'A' to 'Z' do
    for c2 := 'A' to 'Z' do
     if a[c1] > a[c2] then begin
       t := a[c1];
       a[c1] := a[c2];
       a[c2] := t;
     end;
  for c1 := 'A' to 'Z' do
    for c2 := 'A' to 'Z' do
     if b[c1] > b[c2] then begin
       t := b[c1];
       b[c1] := b[c2];
       b[c2] := t;
     end;

  res := false;
  for ch := 'A' to 'Z' do
   if a[ch] <> b[ch] then exit;
  res := true;
end;

procedure done;
begin
  assign(output,'ancient.out');
  rewrite(output);
  if (res) then write('YES')
   else write('NO');
  close(output);
end;

begin
 init;
 solve;
 done;
end.

 