uses crt;
var i,m,j,t,dem,s:integer;
begin
clrscr;
write('Nhap m='); readln(m);
t:=0;
dem:=0;
for i:=1 to m do
begin
s:=0;
for j:=1 to i-1 do
if i mod j=0 then s:=s+j;
if s=i then begin
inc(dem);
t:=t+i;
end;
end;
writeln;
writeln('Tong cac so hoan hao trong pham vi tu 1 toi ',m,' la: ',t);
writeln('So so hoan hao trong pham vi tu 1 toi ',m,' la: ',dem);
readln;
end.