var s,st,max:string;
i,t,j:integer;
begin
write('nhap xau: ');
readln(st);
write('nhapL: ');
readln(s); if st[1]=' ' then j:=0
else j:=1;
for i:=2 to length(st) do
if (st[i]<>' ') and (st[i-1]=' ') then
j:=j+1;
writeln('So tu cua xau la: ',j);
write('Xau nguoc. la: ');
for i:=length(st) downto 1 do
write(st[i]);
st[1]:=upcase(st[1]);
for i:=2 to length(st) do
if (st[i]<>' ')and(st[i-1]=' ') then
st[i]:=upcase(st[i]);
t:=0;
while pos(s,st)<>0 do
begin
t:=t+1;
st:=Delete(st,pos(s,st),length(s));
end;
writeln('so lan xuat hien la ',t);
readln;
end.
