#include <bits/stdc++.h>

using namespace std;
//https://www.geeksforgeeks.org/counting-frequencies-of-array-elements/
void countFreq(int arr[], int n, int k)
{
    int ans = 0;
    unordered_map<int, int> mp;
    for (int i = 0; i < n; i++)
        mp[arr[i]]++;
    for (auto x : mp)
        if(x.second>=k)
        {
            ans++;
        }
    cout << ans << endl;
    for (auto x : mp)
        if(x.second>=k)
        {
            cout << x.first << " ";
        }

}
int main()
{
    int n,k;
    cin >> n >> k;
    int arr[n];
    for(int i=0; i<n; i++)
    {
        cin >> arr[i];
    }
    if(k>n)
    {
        cout << "0" << endl;
        return 0;
    }
    countFreq(arr, n,k);
    return 0;
}