// by Diar Esbol
#include <iostream>
#include <cmath>
#include <climits>
#include <set>
#include <map>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <queue>
#include <numeric>
#include <stack>
#include <assert.h>
 
using namespace std;
 
#define ll long long
#define ld long double
#define pb push_back
#define pop_b pop_back
#define all(x) x.begin(), x.end()
#define ull unsigned long long
#define F first
 
const ll maxv = 10, mod = 1e9 + 7, inf = 2e9;
 
void booster( ) {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}
ll binpow(ll a, ll b) {
    if (b == 0) {
        return 1;
    }
    if (b % 2) {
        return binpow(a, b - 1) * 1LL * a % mod;
    }
    ll res = binpow(a, b / 2);
    return res * 1LL * res % mod;
}
ll lcm(ll a, ll b) {
    return abs(a * b) / gcd(a, b);
}

//char c[maxv][maxv];

void solve( ) {
    booster( );
    ll n, m;
    cin >> n >> m;
    vector<ll>a(m);
    map<ll, ll>cnt;
    set<ll> b;
    for (int i = 0; i < m; i++) {
        cin >> a[i];
    }
    for (int i = 0; i < m; i++) {
        cnt[a[i]]++;
    }
    for (auto& i : cnt) {
        if (i.second > 1) {
            b.insert(i.F);
        }
    }
    cout << b.size() << endl;
    for (auto& i : b) {
        cout << i << " ";
    }
}

int main( ) {
    booster( );
    int testcases = 1;
    //cin >> testcases;
    while(testcases--) {
        solve( );
    }
    return 0;
}
