def D(n,a):
if not a in n:
return "目标不存在,请重新输入"
else:
return n.replace(a,'',1)
def I(n,a,b):
if not a in n:
return "目标不存在,请重新输入"
else:
x=n.rfind(a)
m=list(n)
m.insert(x,b)
z=''.join(m)
return z
def R(n,a,b):
if not a in n:
return "目标不存在,请重新输入"
else:
return n.replace(a,b)
n=str(input())
x=list(map(str,input().split()))
if x[0]=='D':
a=x[1]
n=n
print(D(n,a))
elif x[0]=='I':
a=x[1]
b=x[2]
n=n
print(I(n,a,b))
elif x[0]=='R':
a=x[1]
b=x[2]
n=n
print(R(n,a,b))