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