#include <iostream>

using namespace std;

int main()
{
  int i;
  int j;
  int k;
  int temp;
  long long int A[200000];
  long long int N;
  long long int K;
  cin>>N;
  cin>>K;

  for (i=0 ; i<N ; i++)
  {
    cin>>A[i];
  }


    for (i=0 ; i<N ; i++)
    {
      //cout<<A[i];
    }
    int l=0;
    int m=1;

    long long int seen[N];
    for(int i = 0; i < N; i++)
        seen[i] = 0;

    int br2;

    for(int i = 0; i < N; i++) {
        if(seen[i] == 0) {
            int count = 0;
            for(int j = i; j < N; j++)
                if(A[j] == A[i]) {
                    count += 1;
                    seen[j] = 1;
                }
            if (count>=K)
            { 
            br2++;
            }
        }
        
    }
    cout<<br2<< "\n";
    

    long long int seen1[N];
    for(int i = 0; i < N; i++)
        seen1[i] = 0;

    

    for(int i = 0; i < N; i++) {
        if(seen1[i] == 0) {
            int count1 = 0;
            for(int j = i; j < N; j++)
                if(A[j] == A[i]) {
                    count1 += 1;
                    seen1[j] = 1;
                }
            //cout << A[i] << " occurs " << count << " times" << endl;
            if (count1>=K)
            { 
            cout<<A[i]<< "\t";
            }
        }
        
    }

    





    return 0;
}