words = gets.split(" ")
count = Hash.new(0)
maxWord, maxLength = "", 0
words.each do |word|
  count[word] += 1
  length = word.length
  if length > maxLength
    maxWord = word
    maxLength = length
  end
end
max = count.max{ |a, b| a[1] <=> b[1] }
puts "#{max[0]} #{maxWord}"