#include<bits/stdc++.h> using namespace std; int myHash[256]; bool cmp( pair<int,int> a, pair<int,int> b ) { if( a.second!=b.second ) { return a.second>b.second; } else { return a.first<b.first; } } string str; int main() { while( cin>>str ) { memset( myHash, 0, sizeof(myHash) ); for( char c : str ) { myHash[c]++; } vector< pair<int,int> > solve; for(int i=0; i<256; ++i) { if( myHash[i] ) { solve.push_back( make_pair(i,myHash[i]) ); } } sort( solve.begin(), solve.end(), cmp ); for( auto temp : solve ) { printf("%c", temp.first ); } printf("\n"); } return 0; }