program a;{$APPTYPE CONSOLE}
{$R+,Q+,I+,A+,B-,O-}

var
t,i,j,k,n:longint;
ii,jj:char;
s1,s2: string;
q1,q2: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);
fillchar(q1,sizeof(q1),0);
fillchar(q2,sizeof(q2),0);
for i:=1 to n do inc(q1[s1[i]]);
for i:=1 to n do inc(q2[s2[i]]);

for ii:='A' to 'Z' do begin
	for jj:='A' to 'Y' do begin
		if q1[jj]<q1[succ(jj)] then begin t:=q1[succ(jj)]; q1[succ(jj)]:=q1[jj]; q1[jj]:=t; end;
		if q2[jj]<q2[succ(jj)] then begin t:=q2[succ(jj)]; q2[succ(jj)]:=q2[jj]; q2[jj]:=t; end;
	end;
end;

for ii:='A' to 'Z' do
	if q1[ii]<>q2[ii] then begin writeln('NO'); goto k0; end;

writeln ('YES');

k0:
close(output);
end.
