#include<bits/stdc++.h>

using namespace std;

int main() {
    int n, m;
    cin >> n >> m;
    map <int, int> mp;
    int a[m + 1];
    for (int i = 0; i < m; i++) {
        cin >> a[i];
        mp[a[i]]++;
    }
    int kol = 0;
    vector <int> v;
    for (auto i : mp) {
        if (i.second >= 2) {
            kol++;
            v.push_back(i.first);
        }
    }
    cout << kol << '\n';
    for (int i = 0; i < v.size(); i++) {
        cout << v[i] << ' ';
    }
}
