function SearchSp(S:String; I:Integer):Integer;
var
PartS:String;
I1, I2, I3:Integer;
begin
PartS:=Copy(S, I, Length(S));
I1:=Pos(' ', Copy(S, I, Length(S)));
I2:=Pos(' ', Copy(S, I, Length(S)));
I3:=Pos('.', Copy(S, I, Length(S)));
if (I1=0) and (I2=0) and (I3=0) then
Result:=0
else if (I1=0) and (I2=0) then
Result:=I+I3-1
else if (I1=0) and (I3=0) then
Result:=I+I2-1
else if (I2=0) and (I3=0) then
Result:=I+I1-1
else if I1=0 then
Result:=I+Min(I2, I3)-1
else if I2=0 then
Result:=I+Min(I1, I3)-1
else if I3=0 then
Result:=I+Min(I1, I2)-1
else
Result:=I+Min(Min(I1, I2),Min(I1, I3))-1;
end;