#include<bits/stdc++.h>
using namespace std;
struct node{
int count;
char ch;
};
bool cmp(node A,node B){
if(A.count!=B.count)return A.count>B.count;
if(A.count==B.count){
return A.ch<B.ch;
}
}
node arr[10000];
main(){
string str;
int count[100000]={0};
cin>>str;
int n=str.size();
for(int i=0;i<n;++i){
int j=i+1;
if(str[i]==str[j]){
int t=str[i]-97;
arr[t].ch=str[i];
arr[t].count++;
}
}
sort(arr,arr+26,cmp);
for(int i=0;i<26;++i){
if(arr[i].count>0)cout<<arr[i].ch<<arr[i].ch<<endl;
}
}