#include <iostream>
#include <algorithm>
using namespace std;
int main() {
    long long n,m;
    cin >> n >> m;
    long long arr[m];
    long long temp = 1;
    long long cnt = 0;
    long long ind = 0;
    long long num;
    bool fg = true;
    long long arr2[m];
    for(int i = 0; i < m; i++)
    {
        cin >> arr[i];
    }
    sort(arr, arr+m);
    for(int i = 0; i < m; i++)
    {
        num = count(arr, arr+m, arr[i]);
        if(num >= n)
        {
            for(int f = 0; f < cnt; f++)
            {
                if(arr[i] == arr2[f])
                {
                    fg = false;
                    break;
                }
            }
            if(!fg)
            {
                fg = true;
                continue;
            }
            
            arr2[cnt] = arr[i];
            cnt++;
            
        }
    }
    cout << cnt << endl;
    for(int i =0; i < cnt; i++)
    {
        cout << arr2[i] << " ";
    }
}
