while True: try: s = input() c = {} # 字典键值对存放字符及其个数 key = [] value = [] res = '' for i in s: if i not in c.keys(): c[i] = s.count(i) key = sorted(c.keys()) # 字符ASCII升序 value = sorted(list(set(c.values())),reverse=True) # 个数通过set()去除重复数后转换为列表类型降序排列 i = 0 while i < len(value): for f in key: if s.count(f) == value[i]: res += f i += 1 print(res) except: break