Bob's Overzealous Filter
Bob runs the chat server, and he has banned one word, p. His filter is eager: it watches Alice's
message while she types it, and the instant the text in her input box ends with p, it erases
those last |p| characters. Alice ignores the filter and keeps typing exactly as planned, so
sometimes a deletion glues what came before onto what she types next, and a fresh copy of p
appears, only to be erased as well. What is left in the box when Alice finishes?
Formally, Alice types the string s one character at a time into an initially empty text t.
After each character is appended to the end of t, if t ends with p, the last |p|
characters of t are removed. Print t after all of s has been typed.
Input
The first line contains the string s (1 ≤ |s| ≤ 10^6), the message Alice types.
The second line contains the string p (1 ≤ |p| ≤ 10^6), the banned word.
Both strings consist of lowercase English letters.
Output
Print the final text t on a single line. If t is empty, print EMPTY instead.
Notes
In the first example the text grows as b, ba, baa, baab, baabc → ba, bab, babc →
b, ba, bab. The second deletion removes a copy of abc that was never contiguous in s.
In the second example the filter erases aba as soon as the first three letters are typed, so the
remaining ba never forms another copy.
In the third example every deletion uncovers an a that the next b completes into ab.