program P_A;

{$APPTYPE CONSOLE}

uses
  SysUtils;

var
  i, k, j: integer;
  ok: boolean;
  a, c: array [0..101] of integer;
  s1, s2: string;
  ch: char;
begin
  assign(input, 'ancient.in'); reset(input);
  assign(output, 'ancient.out'); rewrite(output);

  readln(s1);
  readln(s2);

  for ch := 'A' to 'Z' do
  begin
    k := 0;
    while (pos(ch, s1) > 0) do
    begin
      inc(k);
      delete(s1, pos(ch, s1), 1);
    end;
    inc(a[k]);
  end;

  for ch := 'A' to 'Z' do
  begin
    k := 0;
    while (pos(ch, s2)) > 0 do
    begin
      inc(k);
      delete(s2, pos(ch, s2), 1);
    end;
    inc(c[k]);
  end;

  ok := true;
  for i := 1 to 100 do
  if a[i] <> c[i] then
  begin
     ok := false;
     break;
  end;

  if ok then
    writeln('YES')
  else
    writeln('NO');

  close(input);
  close(output);

end.
