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

void countword(string s){
    map<string, int>m;
    stringstream ss(s);
    string word, maximum, maximum_l;
    int Max1 = 0, Max2 = 0;
    while(ss >> word){
        if(word.size() > Max1){
            Max1 = word.size();
            maximum_l = word;
        }
        m[word]++;
    }
    map<string, int>::iterator it;


        for(it = m.begin(); it != m.end(); it++){
        if(Max2 < it->second){
            Max2 = it->second;
            maximum = it->first;
        }
    }
    cout<<maximum<<" "<<maximum_l<<endl;
}


int main()
{
    string s;
    getline(cin, s);
    countword(s);
}

