#pragma GCC optimize("Ofast,unroll-loops")
#pragma GCC target("sse,sse2,sse3,sse4,sse4.1,sse4.2,abm,bmi,bmi2,popcnt,lzcnt,avx,avx2,fma")
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <stack>
#include <vector>
#include <string>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <cmath>
#include <time.h>
#include <deque>
#define ll long long
using namespace std;
using loh = long long; // loh
using flag = bool;
using lohd = long double; // short (4bite) // dolik loh

loh getcount (vector <vector <char>> &a, loh x, loh y) {
	loh fg = 0, size = 1;
	if (x < 9 && a[x+1][y] == '#') {
		fg = 1;
		a[x][y] = 'x';
		x++;
	}
	else if (y < 9 && a[x][y+1] == '#') {
		fg = -1;
		y++;
		a[x][y] = 'x';
	}
	if (fg == -1) {
		while (y <= 9 && fg == -1) {
			size++;
			a[x][y] = 'x';
			if (y < 9 && a[x][y + 1] == '#') {
				y++;
			}
			else {
				fg = 0;
			}
		}
	}
	else if (fg == 1) {
		while (x <= 9 && fg == 1) {
			size++;
			a[x][y] = 'x';
			if (x < 9 && a[x+1][y] == '#') {
				x++;
			}
			else {
				fg = 0;
			}
		}
	}
	return size;
}

int main () {
	ios_base::sync_with_stdio (0);
	cin.tie (0);
	cout.tie (0);
	ll n, m;
	cin >> n >> m;
	multiset <int> Set;
	for (int i = 0; i < m; ++i) {
		int a;
		cin >> a;
		Set.insert (a);
	}
	vector <int> ans;
	while (!Set.empty ()) {
		//cout << *Set.begin () << " " << Set.count (*Set.begin ()) << endl;
		if (Set.count (*Set.begin()) >= n) {
			ans.push_back(*Set.begin());
		}
		Set.erase (*Set.begin());
	}
	cout << ans.size() << endl;
	for (int i = 0; i < ans.size (); ++i) {
		cout << ans[i] << " ";
	}
	/*
	loh n = 10, count = 0;
	vector <vector <char>> mp (n, vector<char> (n));
	for (loh i = 0; i < n; i++) {
		for (loh y = 0; y < n; y++) {
			cin >> mp[i][y];
			if (mp[i][y] == '#') {
				count++;
			}
		}
	} // 4 + 6 + 8 + 4
	if (count != 22) {
		cout << "NO";
		return 0;
	}
	vector <loh> p = { 4, 3, 2, 1 };
	for (loh i = 0; i < n; i++) {
		for (loh y = 0; y < n; y++) {
			if (mp[i][y] == '#') {
				loh sizz = getcount (mp, i, y);
				if (sizz > 4) {
					cout << "NO";
					return 0;
				}
				p[sizz-1]--;
			}
		}
	}
	for (loh i = 0; i < 4; i++) {
		if (p[i] != 0) {
			cout << "NO";
			return 0;
		}
	}
	cout << "YES";
	
	#.#.#.....
.......##.
.#..#.....
.#........
.#.##.....
..........
####...#..
.......#..
.......#..
##........
	*/


}