var line=readline() var count=1 var obj={}
for(let i=0;i<line.length;i++){ if(obj[line[i]]==undefined){ obj[line[i]]=count } if(line.indexOf(line[i])!=i){ obj[line[i]]+=count }
}
var res=''
var arr = Object.keys(obj); for(let i=0; i<arr.length; i++){ fn(); } console.log(res) function fn(){ let max = '' let maxn = 0; for(let k in obj){ if(obj[k] > maxn){ maxn = obj[k]; max = k; } if(obj[k] == maxn){ if(k.charCodeAt() < max.charCodeAt()){ maxn = obj[k]; max = k; } } } res = res + max; delete obj[max]; }