program p2;
const a=' casa';
b=' locuinta';
var t:string;
i, j, p, s: integer;
begin
write(' Dati textul: '); readln(t);
p:=1; t:=' '+t;
while (p<>0) do
begin
p:=pos(a,t);
if p<>0 then
begin
delete(t,p,length(a));
insert(b,t,p);
inc(s);
end;
end;
writeln('Textul modificat: ',t);
writeln(' au fost facute ',s,' substitutii');
end.