# python3
import sys


def btw(text):
    li = []
    #li.append(text)
    x = len(text)
    for i in range(x):
        text = text[x-1]+text[:x-1]
        li.append(text)
    li.sort()
    print(li)
    result = ""
    for i in li:
        result += i[-1]

    return result

print(btw('ACACACAC$'))
print(btw('AGACATA$'))
print(btw('AA$'))
if __name__ == '__main__':
    text = sys.stdin.readline().strip()
    print(btw(text))

3b220b68ba12a5df211b6d516869661b6f46ab3a
<mask token>

<mask token>


def btw(text):
    li = []
    x = len(text)
    for i in range(x):
        text = text[x - 1] + text[:x - 1]
        li.append(text)
    li.sort()
    print(li)
    result = ''
    for i in li:
        result += i[-1]
    return result


<mask token>

<mask token>


def btw(text):
    li = []
    x = len(text)
    for i in range(x):
        text = text[x - 1] + text[:x - 1]
        li.append(text)
    li.sort()
    print(li)
    result = ''
    for i in li:
        result += i[-1]
    return result


print(btw('ACACACAC$'))
print(btw('AGACATA$'))
print(btw('AA$'))
if __name__ == '__main__':
    text = sys.stdin.readline().strip()
    print(btw(text))

import sys


def btw(text):
    li = []
    x = len(text)
    for i in range(x):
        text = text[x - 1] + text[:x - 1]
        li.append(text)
    li.sort()
    print(li)
    result = ''
    for i in li:
        result += i[-1]
    return result


print(btw('ACACACAC$'))
print(btw('AGACATA$'))
print(btw('AA$'))
if __name__ == '__main__':
    text = sys.stdin.readline().strip()
    print(btw(text))

# python3
import sys


def btw(text):
    li = []
    #li.append(text)
    x = len(text)
    for i in range(x):
        text = text[x-1]+text[:x-1]
        li.append(text)
    li.sort()
    print(li)
    result = ""
    for i in li:
        result += i[-1]

    return result

print(btw('ACACACAC$'))
print(btw('AGACATA$'))
print(btw('AA$'))
if __name__ == '__main__':
    text = sys.stdin.readline().strip()
    print(btw(text))
