{PACKING THE SAME CHARACTER}
const   cr:char=chr(13);
	lf:char=chr(10);
var	fi:text;
	fo:file of char;
	o:char;
	fid,fod,g:string;
        i,k:byte;
begin
	write('Input file : ');readln(fid);
	write('Output file: ');readln(fod);
	assign(fi,fid);reset(fi);
	assign(fo,fod);rewrite(fo);
        i:=1;
	while not eof(fi) do
	begin
		readln(fi,g);
                k:=ord(g[0]);
                for i:=1 to k do
                begin
                        o:=g[i];
                        {----}
                        if g[i]+g[i+1]+g[i+2]='for' then
                        begin;o:=chr(1);i:=i+2;end;
                        {----}
                        if g[i]+g[i+1]+g[i+2]+g[i+3]+g[i+4]='while' then
                        begin;o:=chr(2);i:=i+4;end;
                        {----}
                        write(fo,o);
                end;
                write(fo,cr);
                write(fo,lf);
        end;
	close(fo);
end.