#C4553. Largest Valid Integer

    ID: 48104 Type: Default 1000ms 256MiB

Largest Valid Integer

Largest Valid Integer

You are given a string s which may contain letters, digits, and other characters. Your task is to extract all the digits from s and construct the largest possible integer by arranging these digits in descending order.

If the string s does not contain any digit or if the largest digit is '0' (i.e. all digits are zero), the answer should be 0.

Formally, let \( D = \{ d \mid d \text{ is a digit in } s \} \). If \( D \) is empty, output \( 0 \). Otherwise, let \( R \) be the number obtained by sorting \( D \) in descending order. However, if the leading digit of \( R \) is zero then output 0.

Note: The input will be provided via standard input and the output should be printed to standard output.

inputFormat

The input consists of a single line containing a non-empty string s. The string may include alphabets, digits, and other characters.

outputFormat

Output a single line containing the largest valid integer formed by the digits extracted from s. If no valid integer can be formed, output 0.

## sample
abc123
321