#include <iostream> #include <string> #include <vector> #include <algorithm> #include <cstring> using namespace std; struct Node { char c; unsigned cnt; }; bool cmp(Node a, Node b) { if(a.cnt != b.cnt) return a.cnt > b.cnt; else return a.c < b.c; } int main() { string str; unsigned hashTable[200]; while(cin >> str) { memset(hashTable, 0, sizeof(hashTable)); for(auto it = str.begin(); it != str.end(); ++it) { hashTable[*it]++; } vector<Node> vec; Node node; for(char i = '0'; i <= 'z'; ++i) { if(!hashTable[i]) continue; node.c = i; node.cnt = hashTable[i]; vec.push_back(node); } sort(vec.begin(), vec.end(), cmp); for(Node a : vec) { cout << a.c; } cout << endl; } return 0; }