cho.sh
Notes
Loading...

Splitting a Word

Time limit

2s

Memory limit

128 MB

Problem

You are given a word consisting only of lowercase English letters. Split the word into three contiguous parts. Each part must have length at least 1.

Reverse each part separately, then concatenate the reversed parts in the same order as the split. Among all strings that can be made this way, find the lexicographically smallest one.

Input

The first line contains a word consisting of lowercase English letters. Its length is between 3 and 50, inclusive.

Output

Output the lexicographically smallest string that can be made.