//***只要你 目光是瞄准月亮 迷失过 又有何妨***//
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
int n,m;
const int N=1e5+10;
const int mod=1e9+7;
int pre[N];
string s;
int a[15];
map<string,int>mp;
bool cmp(pair<int,string>p1,pair<int,string>p2)
{
    if (p1.first!=p2.first)
    {
        return p1.first>p2.first;
    }
    else
    {
        return p1.second<p2.second;
    }
}
void solve()
{
    getline(cin,s);
    int n=s.length();
    string ans="";
    for (int i=0;i<n;i++)
    {
        if (s[i]==' ')
        {
            if (!ans.empty())
            {
                mp[ans]++;
                ans.clear();
            }

        }
        else
        {
            ans+=s[i];
        }
    }
    if (!ans.empty())mp[ans]++;
    vector<pair<int,string>>st;
    for (auto&[x,y]:mp)
    {
        if (y>=3)
        {
            st.push_back({y,x});
        }
    }
    sort(st.begin(),st.end(),cmp);
    //reverse(st.begin(),st.end(),cmp);
    for (auto&[x,y]:st)
    {
        cout<<y<<'\n';
    }
}
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t;
    t=1;
    while (t--)
    {
        solve();
    }
    return 0;
}