#include<bits/stdc++.h>
using namespace std;

using ll=long long;
using ull=unsigned long long;
using i128=__int128_t;
using u128=__uint128_t;
using ld=long double;

map<string,int>m;

bool cmp(const pair<string,int>& a, const pair<string,int>& b)
{
    if(a.second == b.second) return a.first < b.first;
    return a.second > b.second;
}

void solve()
{
    string s;
    getline(cin,s);
    // 处理输入字符串
    stringstream ss(s);
    string word;
    while(ss >> word)
    {
        m[word]++;
    }
    // 将map内容复制到vector中排序
    vector<pair<string,int>> vec(m.begin(), m.end());
    sort(vec.begin(), vec.end(), cmp);
    
    // 输出出现次数>=3的单词
    for(auto& p : vec)
    {
        if(p.second >= 3) 
        cout << p.first << '\n';
    }
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int t=1;
    //cin >> t;
    
    while(t--)
    {
        solve();
    }
    return 0;
}