HubSpot Interview Question

Write a small application (I choose to do it in Java) to find, given an input string S, and an input number X, which X letters were repeating more in S.