A messy log-processing pipeline sometimes emits fields separated by a chosen delimiter character, but careless concatenation leaves runs of two or more consecutive delimiters, and sometimes a leading or trailing delimiter. Given a line of text S and a single delimiter character D, collapse every maximal run of consecutive D characters in S down to exactly one D, then remove any D that remains at the very start or the very end of the result. Every character of S other than D is left completely untouched (including if it is a space, and D may itself be a space).
Input format
Line 1: the text S (may be empty).
Line 2: a single character D.
Output format
The collapsed-and-trimmed string (may be empty).
Constraints
- 0 ≤ length of
S≤ 200 SandDcontain only printable ASCII characters (0x20–0x7E)