#K72097. Lexicographically Smallest String

    ID: 33677 Type: Default 1000ms 256MiB

Lexicographically Smallest String

Lexicographically Smallest String

You are given a string \(S\). Your task is to remove exactly one character from the string such that the resulting string is the lexicographically smallest possible.

A string \(X\) is considered lexicographically smaller than a string \(Y\) if at the first position where \(X\) and \(Y\) differ, the character in \(X\) comes before the character in \(Y\) in the alphabet. Formally, for two strings \(X\) and \(Y\), \(X < Y\) if there exists an index \(i\) such that \(X_j = Y_j\) for all \(j < i\) and \(X_i < Y_i\).

Example:

  • For \(S = "abc"\), removing the character 'c' gives "ab" which is the smallest possible string after one deletion.
  • For \(S = "bca"\), removing the first character 'b' yields "ca" while removing 'c' gives "ba". Here, "ba" is lexicographically smaller than "ca".

Note: The input string will have a length of at least 2.

inputFormat

The input is read from stdin and consists of a single line containing the string \(S\).

outputFormat

Print to stdout the lexicographically smallest string obtainable by removing exactly one character from \(S\).

## sample
abc
ab