Keep the window as large as possible while at most k characters differ from the most frequent letter inside it.