#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<map>
#include<stack>
#include<cmath>
#include<iomanip>
#include<set>
#include<numeric>
#include<sstream>
#include<random>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rrep(i, st, n) for (int i = st; i < n; ++i)
using pii = pair<int, int>;
//const int inf = 1e9 + 7;
//int dy[] = {0, 0, -1, 1};
//int dx[] = {1, -1, 0, 0};

int main() {
    string s;
    getline(cin, s);
    istringstream ss(s + "\n");
    map<string, int> mp;
    string longer;
    while (1) {
        string t; ss >> t;
        if (!ss.good()) break;
        mp[t]++;
        if (t.size() > longer.size()) longer = t;
    }
    string freq;
    int lerger = 0;
    for (auto it : mp) {
        if (it.second > lerger) {
            lerger = it.second;
            freq = it.first;
        }
    }
    cout << freq << " " << longer << endl;
}

