counts = Hash.new(0)
max = [0, nil]

$<.gets.split.map(&:downcase).each do |word|
  counts[word] += 1
  l = word.length
  max = [l, word] if l > max.first
end
h = counts.invert
puts "#{h[h.keys.max]} #{max.last}"
