a = gets.split
mostchar=""
mostnum=0
maxchar=""
a.each {|v|
  if mostnum < a.count(v)
    mostchar = v
    mostnum = a.count(v)
  end
  if maxchar.size < v.size
    maxchar = v
  end
}

puts mostchar, maxchar