program Project1;

uses
  SysUtils;

var
	str1, str2: string;
  mas1, mas2: array ['A'..'Z'] of integer;
  used1: array ['A'..'Z'] of boolean;
  ch1, ch2: char;
  l, i: integer;
  possible, flag: boolean;

begin
	assignfile(input, 'ancient.in');
  assignfile(output, 'ancient.out');
  reset(input);
  rewrite(output);
  //
  readln(str1);
  readln(str2);
  //
  l := length(str1);
  fillchar(mas1, sizeof(mas1), 0);
  fillchar(mas2, sizeof(mas2), 0);
  for i := 1 to l do
  begin
		inc(mas1[str1[i]]);
		inc(mas2[str2[i]]);
  end;
  //
  possible := true;
  fillchar(used1, sizeof(used1), false);
  for ch2 := 'A' to 'Z' do
  begin
  	flag := false;
		for ch1 := 'A' to 'Z' do
    	if (not used1[ch1]) and (mas1[ch1] = mas2[ch2]) then
      begin
      	flag := true;
      	break;
      end;
    if not flag then
    begin
    	possible := false;
    	break;
    end;
		used1[ch1] := true;
  end;
  //
  if possible then
  	writeln('YES')
  else
  	writeln('NO');
end.

