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

bool cmp(pair<string, int> a1,pair<string, int> a2)
{
    if(a1.second==a2.second) return a1.first<a2.first;
    return a1.second>a2.second;
}

int main() {
    unordered_map<string,int> hash;
    vector<pair<string, int>> ans;
    string t;
    //输入
    while(cin>>t)
        hash[t]++;
    //提取
    for(auto&i:hash)
    {
        if(i.second>=3) ans.push_back(i);
    }
    //排序
    sort(ans.begin(), ans.end(),cmp);
    //输出
    for(auto&i:ans)
    cout<<i.first<<'\n';
    return 0;

}