#include <bits/stdc++.h>

#define endl '\n'

#define debug(x) std::cerr << __FUNCTION__ << ':'<< __LINE__ << ' ' << #x << " = " << x << endl

using ll = long long;
using ull = unsigned long long;

using namespace std;

int main(){
    int n, m, value;
    cin >> n >> m;
    vector<int> was, res;

    for (int i = 0; i < m; i++)
    {
        cin >> value;
        if (find(was.begin(), was.end(), value) == was.end()) {
            was.push_back(value);
        } else {
            res.push_back(value);
            was.erase( find(was.begin(), was.end(), value));
        }
    }
    cout << res.size() << endl; 
    for (auto &&i : res)
    {
        cout << i << ' ';
    }
    cout << endl;
}

