uses crt;
var x,k,i,t,lt,m,j,n:integer;
st:string;
a:array[1..255]of integer;
begin
clrscr;
write('nhap n='); readln(n);
writeln('Cac so Amstrong nho hon hoac bang ',n,' la: ');
for x:=1 to n do
begin
str(x,st);
k:=length(st);
for i:=1 to k do
val(st[i],a[i],m);
t:=0;
for i:=1 to k do
begin
lt:=1;
for j:=1 to k do
lt:=lt*a[i];
t:=t+lt;
end;
if t=x then write(x:4);
end;
readln;
end.