Function CalcMin(s: string): integer;
var min,p,n,c:integer; t:string;
begin
t:=s+' ';
min:=1000;
while t<>'' do
begin
while t[1]=' ' do delete(t,1,1);
p:=pos(' ',t);
if (p=4) then
begin
val(t[1]+t[2]+t[3],n,c);
if c=0 then if n end;
delete(t,1,p);
end;
if min=1000 then CalcMin:=0 else CalcMin:=min;
end;
begin
writeln(CalcMin('123 jkl 105 45 ncmnn 1591'));
end.
Результат:
105