word_count = Hash.new(0)

words =	gets.chomp.split
words.each do |word|
  word_count[word] += 1
end
sorted = word_count.sort{|a,b| b[1] <=> a[1]}
max_size = word_count.sort{|a,b| b[0].size <=> a[0].size}
puts "#{sorted[0][0]} #{max_size[0][0]}"

