#!/usr/bin/env ruby

words = gets.chomp!.split

word_counts = Hash.new(0)
max = ""
words.each do |word|
  word_counts[word] += 1

  max = word if max.length < word.length
end

puts "#{word_counts.sort.pop[0]} #{max}"