#include <iostream>

using namespace std;

int main()
{
    int n,k;
    cin >> n >> k;
    int a[2*n+1],br=0;
    for(int i=0;i<=2*n;i++)a[i]=0;
    while(br<n)
    {
        int i;
        cin >> i;
        a[i+n]++;
        br++;
    }
    br=0;
    for(int i=0;i<=2*n;i++)
    {
        if(a[i]>=k)br++;
    }
    cout << br << endl;
    for(int i=0;i<=2*n;i++)
    {
        if(a[i]>=k) cout << i-n << " ";
    }
}