#include <iostream>
#include <unordered_map>
#include <vector>
#include <algorithm>
using namespace std;

int main() {
    unordered_map<string, int> dict;
    string word;
    while(cin >> word) {
        dict[word]++;
    }

    using mapPtr = unordered_map<string, int>::iterator;
    vector<mapPtr> keywords;
    for(auto it = dict.begin(); it != dict.end(); ++it) {
        if (it->second >= 3)
            keywords.push_back(it);
    }
    sort(keywords.begin(), keywords.end(), [](const mapPtr a, const mapPtr b) {
        if (a->second != b->second)
            return a->second > b->second;
        else
            return a->first < b->first;
    });
    for(const auto it: keywords) {
        cout << it->first << endl;
    }
}
// 64 位输出请用 printf("%lld")