//Failure will never overtake me if my determination to succeed is strong enough
#include <bits/stdc++.h>

using namespace std;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);

    int n, k;
    cin >> n >> k;
    map<int, int> cnt;
    for(int i = 0; i < n; i++)
    {
        int x;
        cin >> x;
        cnt[x]++;
    }

    vector<int> v;
    int rez = 0;
    for(auto i: cnt)
    {
        if(i.second >= k)
        {
            rez++;
            v.push_back(i.first);
        }
    }

    cout << rez << endl;
    for(auto i: v)
        cout << i << " ";

}