program ancient;

{$APPTYPE CONSOLE}

uses
  SysUtils;

var
  letters1, letters2: array[0..255] of integer;
  i,j,k,n,t: integer;
  s1, s2, s3: string;
  yes: boolean;

procedure sameLetters(s1, s2: string);
var
  i: integer;
  k: boolean;
begin
  for i := 1 to length(s1) do begin
    letters1[ord(s1[i])-65] := letters1[ord(s1[i])-65] + 1;
    letters2[ord(s2[i])-65] := letters2[ord(s2[i])-65] + 1;
  end;
  for i := 0 to 25  do begin
  k := false;
    for j := 0 to 25 do begin
      if letters1[i] = letters2[j] then k := true;
    end;
    if not k then begin writeln('NO'); close(output); exit; end;
  end;
  writeln('YES');
  close(output);
end;

begin
  assign(input, 'ancient.in');
  assign(output, 'ancient.out');
  reset(input);
  rewrite(output);

  readln(s1);
  readln(s2);

  sameLetters(s1, s2);
end.
