program a;{$APPTYPE CONSOLE}

type symbol=record c:char; l:longint; end;
var
i,j,k,n, last:longint;
	s1,s2: string;
	t: char;
sym1,sym2:array['A'..'Z'] of longint;
label k0;

begin
assign(input,'ancient.in'); reset(input);
assign(output,'ancient.out'); rewrite(output);
readln (s1); readln (s2);
n:=length(s1);

for i:=1 to n do begin
	inc(sym1[s1[i]]);
	inc(sym2[s2[i]]);
	end;

for i:=1 to n do begin
	for j:=1 to n-1 do begin
		if sym1[s1[j]]<sym1[s1[j+1]] then begin t:=s1[j]; s1[j]:=s1[j+1]; s1[j+1]:=t; end;
		if sym2[s2[j]]<sym2[s2[j+1]] then begin t:=s2[j]; s2[j]:=s2[j+1]; s2[j+1]:=t; end;
	end;
end;

for k:=1 to (length(s1)-1) do
begin
 if (s1[k]=s1[k+1]) and (s2[k]<>s2[k+1]) then begin writeln('NO'); goto k0; end;
 if (s2[k]=s2[k+1]) and (s1[k]<>s1[k+1]) then begin writeln('NO'); goto k0; end;
end;

writeln ('YES');
k0:
close(output);
end.                          s
