const
alpha: set of char = ['A'..'Z'];
type
st= string[90];
var
fl: text;
b: st;
s: integer;
i,kol,k: byte;
begin
writeln;
assign(fl,'dat.txt');
rewrite(fl);
writeln('vvedite 4 rjadka');
for i:=1 to 4 do begin
readln(b);
writeln(fl,b)
end;
close(fl);
reset(fl);
writeln;
writeln('vvedite chislo');
readln(s);
kol:=0;
while not eof(fl) do begin
readln(fl,b);
k:=0;
for i:=1 to length(b) do begin
if UpCase(b[i]) in alpha then Inc(k)
else begin
if k=s then Inc(kol);
k:=0;
end
end;
if k=s then Inc(kol)
end;
close(fl);
writeln('kolichestvo ',kol);
writeln;
readln;
end.