#include <iostream>
using namespace std;
int main() {
string password;
cin >> password;
int count[26] = {0};
for (char c : password) {
count[c - 'A']++;
}
int n = 0;
for (int i = 0; i < 26; i++) {
if (count[i] > 0) {
n++;
}
}
char s[n];
int count_2[n];
int list = 0;
for (int i = 0; i < 26; i++) {
if (count[i] > 0) {
s[list] = 'A' + i;
count_2[list] = count[i];
list++;
}
}
for (int i = 0; i < n - 1; i++) {
for (int j = 0; j < n - i - 1; j++) {
if (count_2[j] < count_2[j + 1]) {
int temp = count_2[j];
count_2[j] = count_2[j + 1];
count_2[j + 1] = temp;
char tempChar = s[j];
s[j] = s[j + 1];
s[j + 1] = tempChar;
} else if (count_2[j] == count_2[j + 1] && s[j] > s[j + 1]) {
int temp = count_2[j];
count_2[j] = count_2[j + 1];
count_2[j + 1] = temp;
char tempChar = s[j];
s[j] = s[j + 1];
s[j + 1] = tempChar;
}
}
}
for (int i = 0; i < n; i++) {
cout << s[i];
}
cout << endl;
return 0;
}