import java.util.*;
/**
* @author hll[yellowdradra@foxmail.com]
* @since 2023-04-01 10:59
**/
public class Main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
char[] chars = in.nextLine().toCharArray();
Map<Character, Integer> counter = new HashMap<>(chars.length);
for (char c : chars) {
counter.compute(c, (k, v) -> v == null ? 1 : ++v);
}
Set<Map.Entry<Character, Integer>> set = new TreeSet<>((e1, e2) -> e2.getValue() - e1.getValue() == 0 ?
e1.getKey() - e2.getKey() : e2.getValue() - e1.getValue()
);
set.addAll(counter.entrySet());
set.forEach(e -> System.out.print(e.getKey()));
}
}