#include <bits/stdc++.h>
#define pb push_back
#define ll long long
using namespace std;

const ll N = 3e5 + 7;
const ll inf = 1e18;
const ll mod = 1e9 + 7;

int n, m, c[N];

set <int> st, ans;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

    cin >> n >> m;

    for (int i = 0; i < m; i++) {
        cin >> c[i];
    }

    for (int i = 0; i < m; i++) {
        if (st.find(c[i]) != st.end()) {
            ans.insert(c[i]);
        }

        st.insert(c[i]);
    }

    cout << ans.size() << '\n';

    for (auto it:ans) {
        cout << it << " ";
    }
}