using System;
using System.Collections.Generic;
class Program {
    static void Main() {
        string s = Console.ReadLine();
        string[] a = s.Split(" ");
        int n = int.Parse(a[0]);
        int k = int.Parse(a[1]);
        s = Console.ReadLine();
        a = s.Split(" ");
        int i, j, x, y;
        int br = 0;
        List<string> rez = new List<string>();
        List<string> REZ = new List<string>();
        for(i = 0;i < n;i++) {
            x = int.Parse(a[i]);
            for(j = 0;j < n;j++) {
                y = int.Parse(a[j]);
                if(x == y){ br++; }
            }
            if(br >= k){
                rez.Add(x.ToString());
            }
            br = 0;
        }
        for(i = -n;i <= n;i++){
            if(rez.Contains(i.ToString())) {
                REZ.Add(i.ToString());
            }
        }
        br = REZ.Count;
        Console.WriteLine(br);
        foreach(string e in REZ){ Console.Write("{0} ",e); }
    }
}