line = gets
line = line.split(" ")
moji = line.max_by{|i| i.size}

count = Hash.new(0)
line.each do |elem|
  count[elem] += 1
end
count = count.max{|a,b| a[1]<=>b[1]}
hindo = count[0]
puts [hindo,moji].join(" ")
