-----Description-----
This task requires writing a Lean 4 method that returns the k most frequent elements from a list of integers. The method should count the frequency of each distinct element in the list and return the k elements with the highest frequency.

-----Input-----
The input consists of two values:
nums: A list of integers, possibly with duplicates.
k: A natural number indicating how many of the most frequent elements to return. Assimng k <= # of distinct elements in nums. 

-----Output-----
The output is a list of integers:
Returns exactly k integers representing the elements that appear most frequently in the input list in the order form the higher frequency to lower frequency.
If two numbers have the same frequency, use the order of the first occurance in nums.
