var
main,sub:string; //主串 和 子串
count,p:integer;
begin
count:=0;
main:='adfjokggglleokffffok';
sub:='ok';
while length(main)>0 do
begin
p:=pos(sub,main);
if p=0 then break//没有找到
else
begin
delete(main,1,p+length(sub));
count:=count+1;
end;
end;
showmessage(inttostr(count));
end;