let str; while( str = readline()){ let arr = str.split(''); let obj = {}; let res = []; arr.forEach(item => { for(let i = 0; i < arr.length; i++){ if(item == arr[i]){ if(obj[item]){ obj[item]++; } else{ obj[item] = 1; res.push(item); } } } }) res.sort((a, b) => { if(obj[a] == obj[b]){ return a.charCodeAt(0) - b.charCodeAt(0); } else{ return obj[b] - obj[a] } }) console.log(res.join('')) }