import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Scanner;
import java.util.Set;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        int n = scanner.nextInt();
        int m = scanner.nextInt();

        Map<Integer, Integer> mp = new HashMap<>();
        Set<Integer> ans = new HashSet<>();

        while (m-- > 0) {
            int x = scanner.nextInt();
            mp.put(x, mp.getOrDefault(x, 0) + 1);
            if (mp.get(x) >= n) {
                ans.add(x);
            }
        }

        System.out.println(ans.size());
        for (int i : ans) {
            System.out.print(i + " ");
        }
    }
}
