#include <bits/stdc++.h>
#define ll long long
#define f first
#define s sceond
using namespace std;

int main()
{
     int n,m;
     cin >> n >> m;
     set <int> a;
     map <int,int> s;
     vector <int> ans;
     for (int i=0;i<m;i++) {
         int now;
         cin >> now;
       if (a.find(now)==a.end()) {
             a.insert(now);
             s[now]++;
       } else {
          s[now]++;
       }  if (s[now]>=n) {
           ans.push_back(now);
           s[now]=-1e9;
       }
     } cout << ans.size() << endl; 
      for (auto now : ans) {
          cout << now << " ";
      }
    return 0;
}