program Project2;

{$APPTYPE CONSOLE}

var
  s1, s2: string[100];
  a: array ['A'..'Z'] of integer;
  sum1, sum2: array [0..100] of integer;
  ans: boolean;

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

procedure solve;
var
  i: integer;
  c: char;
begin
  fillchar(a, sizeof(a), 0);

  for i := 1 to length(s1) do
    inc(a[s1[i]]);
  for c := 'A' to 'Z' do
    inc(sum1[a[c]]);

  fillchar(a, sizeof(a), 0);

  for i := 1 to length(s2) do
    inc(a[s2[i]]);

  for c := 'A' to 'Z' do
    inc(sum2[a[c]]);

  for i := 1 to 100 do
    if sum1[i] <> sum2[i] then begin
      ans := false;
      exit;
    end;
  ans := true;
end;

procedure print;
begin
  assign(output, 'ancient.out');
  if ans then
    writeln('YES')
  else
    writeln('NO');
  close(output);
end;

begin
  scan;
  solve;
  print;
end.
