using System;
using System.Collections.Generic;
class PIKADO {
    static void Main() {
        string s = Console.ReadLine();
        string[] a = s.Split(null);
        int n = int.Parse(a[0]);
        int k = int.Parse(a[1]);
        s = Console.ReadLine();
        a = s.Split(null);
        int i, j, x, y;
        int br = 0;
        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.Contains(x.ToString())){
                rez.Add(x.ToString());
            }
            br = 0;
        }
        Console.WriteLine(rez.Count);
        foreach(string e in rez) {Console.Write("{0} ", e);
        }
    }
}