#include <algorithm>
#include <iostream>
#include <map>
#include <set>
#include <vector>
using namespace std;
int main() {
string str;
cin >> str;
// 1. 按 ASCII码的顺序从小到大排序
sort(str.begin(), str.end());
// 2. 有序map ,去重
map<char, int> mp;
for (char ch : str) {
mp[ch] ++;
}
// 3. 按照从大到小的顺序,把次数存到set中,去重
set<int, greater<>> cishu;
for (auto & it : mp) {
cishu.insert(it.second);
}
// 4. 按照次数进行遍历输出
for (int c : cishu) {
for (auto & it : mp) {
if (it.second == c) {
cout << it.first;
}
}
}
cout << endl;
return 0;
}
// 64 位输出请用 printf("%lld")