def sort_characters_by_count_and_ascii(input_string):
    # 统计字符出现次数并存储为字典
    char_counts = {}
    for char in input_string:
        if char.isalnum():
            char_counts[char] = char_counts.get(char, 0) + 1
            
    # 根据字符出现次数和ASCII码排序
    sorted_chars = sorted(char_counts.keys(), key=lambda x: (-char_counts[x], ord(x)))
    
    # 输出排序后的字符
    output = ''.join(sorted_chars)
    return output

input_str = str(input())
output_str = sort_characters_by_count_and_ascii(input_str)
print(output_str)  # 输出: "cda"