cswork / OAOpen practice workspace

Jane StreetOA #1

Transform String

EasyJudge-ready

Topics (AI-labelled)Stacks & HeapsStrings

The string contains only A, B, C, and D. You may repeatedly delete any adjacent A/B pair (in either order) or C/D pair (in either order). Output any result that cannot be reduced further.

This site adds a standard input/output protocol.

Input

A single line with the string S; an empty string is given as an empty line.

Output

Output an irreducible string; if the result is empty, output an empty line.

Example 1

Input:

AB

Output:

Example 2

Input:

ABCD

Output:

Example 3

Input:

A

Output:

A

Editorial

Loading solution…