import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        while (in.hasNext()) {
            String str = in.nextLine();
            char[] chars = str.toCharArray();
            // 获取每个字符出现的次数
            Map<Character, Integer> map = new HashMap<>();
            for (char c : chars) {
                map.put(c, map.getOrDefault(c, 0) + 1);
            }

            // 按照次数排序,次数相同则按照ASCII码排序
            List<Map.Entry<Character, Integer>> list = new ArrayList<>(map.entrySet());
            list.sort((o1, o2) -> {
                if (!o1.getValue().equals(o2.getValue())) {
                    return o2.getValue() - o1.getValue();
                } else {
                    return (char) (o1.getKey()) - (char) (o2.getKey());
                }
            });
            list.forEach(s -> System.out.print(s.getKey()));
        }
    }
}