#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n, m; cin >> n >> m;
    vector <int> arr(m);
    set <int> st;
    for (int &i : arr) {cin >> i;}
    for (int i = n - 1; i < m; i += n)
    {
        st.insert(arr[i]);
    }
    cout<<st.size()<<"\n";
    for (auto i : st)
    {
        cout<<i<<" ";
    }
}
