let str;
while ((str = readline())) {
let obj = {};
for (let i = 0; i < str.length; i++) {
obj[str[i]] = (obj[str[i]] || 0) + 1;
}
let arr = Object.entries(obj);
arr.sort((a, b) => {
if (a[1] === b[1]) {
return a[0].charCodeAt() - b[0].charCodeAt();
} else {
return b[1] - a[1];
}
});
print(arr.reduce((pre, cur) => pre + cur[0], ""));
}