program edit;
var
s:string;
ch,ch1,ch2:char;
procedure del;
var
i:integer;
begin
read(ch);
readln(ch1);
for i:=1 to length(s) do
if s[i]=ch1 then
break;
delete(s,i,1);
end;
procedure add;
var
i,x:integer;
begin
read(ch);
read(ch1);
read(ch);
readln(ch2);
for i:=1 to length(s) do
if s[i]=ch1 then
x:=i;
insert(ch2,s,x);
//s:=copy(s,1,x-1)+ch2+copy(s,x+1,length(s)-x);
end;
procedure change;
var
i,x:integer;
flag:boolean;
begin
flag:=false;
read(ch);
read(ch1);
read(ch);
readln(ch2);
for i:=1 to length(s) do
if s[i]=ch1 then
begin
flag:=true;
x:=i;
s:=copy(s,1,x-1)+ch2+copy(s,x+1,length(s)-x);
end;
if not flag then
s:='error';
end;
begin
assign(input,'edit.in');reset(input);
assign(output,'edit.out');rewrite(output);
readln(s);
read(ch);
if ch='D' then
del;
if ch='I' then
add;
if ch='R' then
change;
writeln(s);
readln;
readln;
close(input);close(output);
end.