cswork / OAOpen practice workspace

PalantirOA #1

Swap Parity

EasyJudge-ready

Topics (AI-labelled)StringsGreedy

You are given a digit string. You may swap two adjacent digits of the same parity (both odd or both even) any number of times. Find the largest number obtainable. Only adjacent digits can be swapped, so an odd digit can never move past an even digit, and vice versa.

Input

One line containing a string num consisting only of the digits 0–9, with 1≤length≤100000.

Output

Output the largest obtainable number as a string.

Example 1

Input:

7596801

Output:

9758601

Example 2

Input:

0082663

Output:

8662003

Example 3

Input:

0

Output:

0

Editorial

Loading solution…