program WordCount;
uses CRT;
var
B, S, W: String;
C, I: Byte;
begin
Write('Vvedite stroky: ');
ReadLn(S);
Write('Vvedite slovo: ');
ReadLn(W);
S := S + ' ';
C := 0;
B := '';
for I := 1 to Length(S) do
if S[I] <> ' ' then
B := B + S[I]
else
if B <> '' then
begin
if B = W then
Inc(C);
B := '';
end;
WriteLn('Slovo ', W, ' vstretilos ', C, ' raz(a).');
ReadLn;
end.