#P4824. Censoring the Magazine Text

    ID: 18068 Type: Default 1000ms 256MiB

Censoring the Magazine Text

Censoring the Magazine Text

Farmer John has purchased a subscription to Good Hooveskeeping magazine for his cows, but an inappropriate article on how to cook the perfect steak has appeared. To prevent his cows from reading it, FJ has taken all the text to form a string \(S\) and decided to censor out the substring \(T\). The censorship process is as follows: repeatedly find the first occurrence of \(T\) in \(S\) and delete it. Note that deleting an occurrence may create a new occurrence of \(T\) that was not present before. Continue this process until no occurrence of \(T\) exists in \(S\). Your task is to output the final contents of \(S\) after all deletions are complete.

Input Constraints: The length of \(S\) is at most \(10^6\) characters.

Hint: Be careful that after deleting an occurrence, new occurrences of \(T\) can appear. The deletion process always targets the first occurrence in the current string.

inputFormat

The input consists of two lines:

  • The first line contains the string \(S\), representing the magazine text.
  • The second line contains the substring \(T\) which needs to be censored out.

Note that \(S\) may be up to \(10^6\) characters long.

outputFormat

Output the final contents of string \(S\) after repeatedly deleting the first occurrence of \(T\) until no such occurrence exists.

sample

whatthemomooofun
moo
whattheofun