const
  InFile  = 'ancient.in';
  OutFile = 'ancient.out';

var
  inf, outf : textfile;
  st1, st2 : string;
  a1,a2 : array [1..100] of integer;
  dif : integer;
  fl : boolean;

procedure Init;
begin
  Assign(inf, InFile);
  Assign(outf, OutFile);
  Reset(inf);
  Rewrite(outf);
  readln(inf, st1);
  readln(inf, st2);
end;

procedure Run;
var q: string;
n : integer;
l, i : integer;
j, k, m : integer;
begin
  l := 0;
  while length(st1) > 0 do
  begin
    l := l + 1;
    q := copy(st1, 1, 1);
    delete (st1, 1, 1);
    i := 1;
    n := 1;
    while i <= length(st1) do 
    begin
      if copy(st1, i, 1) = q then
      begin
        delete(st1, i, 1);
        inc (n);
      end
      else 
      begin
        i := i + 1;
      end;
    end;
    a1[l] := n;
  end;
  for j := 1 to l do
    for k := 2 to l do
    begin
      if (a1[k-1] < a1[k]) then
      begin
        m := a1[k-1];
        a1[k-1] := a1[k];
        a1[k] := m;
      end;
    end;

  
  l := 0;
  while length(st2) > 0 do
  begin
    l := l + 1;
    q := copy(st2, 1, 1);
    delete (st2, 1, 1);
    i := 1;
    n := 1;
    while i <= length(st2) do 
    begin
      if copy(st2, i, 1) = q then
      begin
        delete(st2, i, 1);
        inc (n);
      end
      else 
      begin
        i := i + 1;
      end;
    end;
    a2[l] := n;
  end;
  for j := 1 to l do
    for k := 2 to l do
    begin
      if (a2[k-1] < a2[k]) then
      begin
        m := a2[k-1];
        a2[k-1] := a2[k];
        a2[k] := m;
      end;
    end;
  dif := l;
  fl := true;
  for i := 1 to l do 
  begin
    if (a1[i] <> a2[i]) then
      fl := false;
  end;
end;

procedure Done;
begin
  if (fl) then
    write(outf, 'YES')
  else
    write(outf, 'NO');
  Close(inf);
  Close(outf);
end;


begin
  Init;
  Run;
  Done;
  Halt(0);
end.