uses crt;
var st:string[30];
i,d,dem,dem1:integer;
ktu:char;
begin
clrscr;
write('Nhap cau:'); readln(st);
d:=length(st);
while st[1]=#32 do
begin
delete(st,1,1);
d:=length(st);
end;
while st[length(st)]=#32 do
begin
delete(st,length(st),1);
end;
for i:=1 to length(st) do
if (st[i]=#32) and (st[i+1]=#32) then delete(st,i,1);
dem:=0;
for i:=1 to length(st) do
if st[i]=#32 then inc(dem);
writeln('So tu trong cau la: ',dem-1);
write('Nhap ki tu:'); readln(ktu);
dem1:=0;
for i:=1 to length(st) do
if (st[i]=#32) and (st[i+1]=ktu) then inc(dem1);
writeln('Trong cau co ',dem1,' tu bat dau bang ki tu ',ktu);
readln;
end.