#include <bits/stdc++.h>

#define endl '\n'

#define debug(x) std::cerr << __FUNCTION__ << ':'<< __LINE__ << ' ' << #x << " = " << x << endl


int main(){
    int n, m, value;
    std::cin >> n >> m;
    --n;
    std::vector<int> was;
    std::unordered_set<int> res;

    for (int i = 0; i < m; i++)
    {
        std::cin >> value;

        if (count(was.begin(), was.end(), value) >= n) 
            res.insert(value);
         else 
            was.push_back(value);
    }
    
    std::cout << res.size() << endl; 
    for (auto &&i : res)
    {
        std::cout << i << ' ';
    }
}

