program a;{$APPTYPE CONSOLE}

var
i,j,k,n, last:longint;
	s1,s2: string;
	t: char;

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
	for j:=1 to n-1 do begin
		if s1[j]<s1[j+1] then begin t:=s1[j]; s1[j]:=s1[j+1]; s1[j+1]:=t; end;
		if s2[j]<s2[j+1] then begin t:=s2[j]; s2[j]:=s2[j+1]; s2[j+1]:=t; end;
	end;
end;
last:=1;
for k:=1 to length(s1) do
begin
 if (s1[k]=s1[k+1]) and (s2[k]<>s2[k+1]) then begin writeln('NO');
 halt; end;
end;

//while k<=length(s1) do begin
	//	repeat inc(k) until (s1[k]<>s1[last]) or (k=length(s1));
	 //	for j:=last to k-1 do if s2[i]<>s2[last] then nosol;
//end;
writeln ('YES');
close(output);
end.
