#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n, m; cin >> n >> m;
    vector <int> arr(m);
    for (int &i : arr) {cin >> i;}
    map <int, int> mp;
    for (int i = 1; i < m; i++)
    {
        mp[arr[i]]++;
    }
    int sum = 0;
    for (auto &i : mp)
    {
        if (i.second >= 2)
        {
            sum++;
        }
    }
    cout<<sum<<"\n";
    for (auto &i : mp)
    {
        if (i.second >= 2)
        {
            cout<<i.first<<" ";
        }
    }
}
