word = input()
count = {}
result = []
for i in word:
    if i in count:
        count[i] = count[i] + 1
    else:
        count[i] = 1
for k in count.keys():
    for v in count.values():
        if count[k] > v:
            if k * count[k] not in result:
                result.append(k * count[k])
resultStr = "".join(result)
lastResult = []
for j in word:
    if j in resultStr:
        lastResult.append(j)
print("".join(lastResult))