text = input()
word = input()
result = []
i = 0
while i < len(text):
    if text[i:i+len(word)] == word:
        if i == 0 or text[i-1] == ' ':
            if i + len(word) == len(text) or not text[i+len(word)].isalpha():
                if i > 0 and text[i-1] == ' ':
                    result = result[:-1]
                i += len(word)
                while i < len(text) and text[i] == ' ':
                    i += 1
                continue
    result.append(text[i])
    i += 1
print(''.join(result))