시간 제한메모리 제한제출정답맞힌 사람정답 비율
1.5 초 (추가 시간 없음) 128 MB518783956820.358%

문제

김상근은 창영마을에서의 권력을 유지하기 위해 신문을 검열하려고 한다.

상근이는 텍스트 T에서 A라는 단어를 다음과 같은 알고리즘을 이용해서 모두 없애려고 한다.

  1. T에 A가 없으면 알고리즘을 종료한다.
  2. T에서 처음 등장하는 A를 찾은 뒤, 삭제한다.
  3. T에 A가 없으면 알고리즘을 종료한다.
  4. T에서 마지막으로 등장하는 A를 찾은 뒤, 삭제한다.
  5. 1번으로 돌아간다.

상근이는 마을을 지배해야하기 때문에, 검열을 할 시간이 없다. 상근이의 검열을 대신해주는 프로그램을 작성하시오. 

입력

첫째 줄에 단어 A가, 둘째 줄에 텍스트 T가 주어진다. A와 T는 알파벳 소문자로만 이루어져 있고, A는 최대 25자, T는 최대 300,000자이다.

출력

검열을 한 이후의 텍스트를 출력한다.

예제 입력 1

ne
lukanevolisarmu

예제 출력 1

lukavolisarmu

예제 입력 2

aba
ababacccababa

예제 출력 2

bacccab

예제 입력 3

banana
babananananadeda

예제 출력 3

deda
W3sicHJvYmxlbV9pZCI6IjMxMTEiLCJwcm9ibGVtX2xhbmciOiIwIiwidGl0bGUiOiJcdWFjODBcdWM1ZjQiLCJkZXNjcmlwdGlvbiI6IjxwPlx1YWU0MFx1YzBjMVx1YWRmY1x1Yzc0MCBcdWNjM2RcdWM2MDFcdWI5YzhcdWM3NDRcdWM1ZDBcdWMxMWNcdWM3NTggXHVhZDhjXHViODI1XHVjNzQ0IFx1YzcyMFx1YzljMFx1ZDU1OFx1YWUzMCBcdWM3MDRcdWQ1NzQgXHVjMmUwXHViYjM4XHVjNzQ0IFx1YWM4MFx1YzVmNFx1ZDU1OFx1YjgyNFx1YWNlMCBcdWQ1NWNcdWIyZTQuPFwvcD5cclxuXHJcbjxwPlx1YzBjMVx1YWRmY1x1Yzc3NFx1YjI5NCBcdWQxNGRcdWMyYTRcdWQyYjggVFx1YzVkMFx1YzExYyBBX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