#include <bits/stdc++.h>

using i64 = long long;

int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);

    int n, m;
    std::cin >> n >> m;

    std::map<int, int> cnt;
    for (int i = 0; i < m; i++) {
        int x;
        std::cin >> x;

        cnt[x]++;
    }

    std::vector<int> ans;
    for (auto [x, y]: cnt) {
        if (y >= n)
            ans.push_back(x);
    }

    std::cout << ans.size() << "\n";
    for (int x: ans) 
        std::cout << x << " ";

    return 0;
}